feat: add 'vol' command
This commit is contained in:
1 parent
420a7c996c
commit
80b5beb17d
17 files changed
+284
-17
No files matched your search
+18
-10
@@ -350,10 +350,10 @@ namespace Fs::Vfs {
|
||||
vfsLock.Release();
|
||||
return count;
|
||||
}
|
||||
|
||||
int VfsDriveLabel(int driveNumber, char* outLabel, int maxLen) {
|
||||
if (outLabel == nullptr || maxLen <= 0) return -1;
|
||||
outLabel[0] = '\0';
|
||||
static int CopyDriveString(int driveNumber, const char* (*FsDriver::*hook)(void*),
|
||||
char* out, int maxLen) {
|
||||
if (out == nullptr || maxLen <= 0) return -1;
|
||||
out[0] = '\0';
|
||||
|
||||
vfsLock.Acquire();
|
||||
FsDriver* driver = DriverForLocked(driveNumber);
|
||||
@@ -362,28 +362,36 @@ namespace Fs::Vfs {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (driver->GetLabel == nullptr) {
|
||||
if (driver->*hook == nullptr) {
|
||||
vfsLock.Release();
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char* label = driver->GetLabel(driver->ctx);
|
||||
if (label == nullptr || label[0] == '\0') {
|
||||
const char* value = (driver->*hook)(driver->ctx);
|
||||
if (value == nullptr || value[0] == '\0') {
|
||||
vfsLock.Release();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int copied = 0;
|
||||
while (label[copied] != '\0' && copied < maxLen - 1) {
|
||||
outLabel[copied] = label[copied];
|
||||
while (value[copied] != '\0' && copied < maxLen - 1) {
|
||||
out[copied] = value[copied];
|
||||
copied++;
|
||||
}
|
||||
outLabel[copied] = '\0';
|
||||
out[copied] = '\0';
|
||||
|
||||
vfsLock.Release();
|
||||
return copied;
|
||||
}
|
||||
|
||||
int VfsDriveLabel(int driveNumber, char* outLabel, int maxLen) {
|
||||
return CopyDriveString(driveNumber, &FsDriver::GetLabel, outLabel, maxLen);
|
||||
}
|
||||
|
||||
int VfsDriveFsType(int driveNumber, char* outType, int maxLen) {
|
||||
return CopyDriveString(driveNumber, &FsDriver::GetFsType, outType, maxLen);
|
||||
}
|
||||
|
||||
int VfsRename(const char* oldPath, const char* newPath) {
|
||||
int oldDrive, newDrive;
|
||||
const char* oldLocal;
|
||||
|
||||
Reference in new issue
Block a user