Skip to content

Fix getting file size for NativeFileInfo #2996

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ HRESULT Library_nf_sys_io_filesystem_System_IO_NativeFindFile::GetFileInfo___STA

NANOCLR_CHECK_HRESULT(Library_nf_sys_io_filesystem_System_IO_NativeIO::FindVolume(stack.Arg0(), driver, path));

// zero initialize the fileInfo
memset(&fileInfo, 0, sizeof(FS_FILEINFO));

NANOCLR_CHECK_HRESULT(driver->GetFileInfo(path, &fileInfo, &found));

if (found)
{
// find <NativeFindFile> type definition, don't bother checking the result as it exists for sure
g_CLR_RT_TypeSystem.FindTypeDef("NativeFindFile", "System.IO", nativeFindFileTypeDef);
g_CLR_RT_TypeSystem.FindTypeDef("NativeFileInfo", "System.IO", nativeFindFileTypeDef);

// create an instance of <NativeFindFile>
NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(top, nativeFindFileTypeDef));
Expand Down
3 changes: 3 additions & 0 deletions targets/ChibiOS/_FatFs/fatfs_FS_Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,9 @@ HRESULT FATFS_FS_Driver::GetFileInfo(const VOLUME_ID *volume, const char *path,
// store the attributes
fileInfo->Attributes = info.fattrib;

// set the file size
fileInfo->Size = info.fsize;

// no need to set the file name details as managed code already has this info
}

Expand Down
4 changes: 3 additions & 1 deletion targets/ChibiOS/_littlefs/littlefs_FS_Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,8 @@ HRESULT LITTLEFS_FS_Driver::GetFileInfo(const VOLUME_ID *volume, const char *pat
&fileInfo->Attributes,
NANO_LITTLEFS_ATTRIBUTE_SIZE);

fileInfo->Size = info.size;

// no need to set the file name details as managed code already has this info
}

Expand Down Expand Up @@ -1212,4 +1214,4 @@ FILESYSTEM_DRIVER_INTERFACE g_LITTLEFS_FILE_SYSTEM_DriverInterface = {

"LITTLEFS",
0,
};
};
13 changes: 13 additions & 0 deletions targets/ESP32/_FatFs/fatfs_FS_Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,9 +642,22 @@ HRESULT FATFS_FS_Driver::GetFileInfo(const VOLUME_ID *volume, const char *path,
// set found flag
*found = true;

// store the attributes
if (S_ISDIR(info.fattrib))
{
fileInfo->Attributes = FileAttributes::FileAttributes_Directory;
}
else
{
fileInfo->Attributes = FileAttributes::FileAttributes_Archive;
}

// store the attributes
fileInfo->Attributes = info.fattrib;

// set the file size
fileInfo->Size = info.fsize;

// no need to set the file name details as managed code already has this info
}

Expand Down
4 changes: 2 additions & 2 deletions targets/ESP32/_IDF/esp32/app_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ void app_main()
ESP_ERROR_CHECK(nvs_flash_init());

// start receiver task pinned to core 1
xTaskCreatePinnedToCore(&receiver_task, "ReceiverThread", 3072, NULL, 5, NULL, 0);
xTaskCreatePinnedToCore(&receiver_task, "ReceiverThread", 3072, NULL, 5, NULL, 1);

// start the CLR main task pinned to core 0
xTaskCreatePinnedToCore(&main_task, "main_task", 15000, NULL, 5, NULL, 1);
xTaskCreatePinnedToCore(&main_task, "main_task", 15000, NULL, 5, NULL, 0);
}
3 changes: 3 additions & 0 deletions targets/ESP32/_littlefs/littlefs_FS_Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,9 @@ HRESULT LITTLEFS_FS_Driver::GetFileInfo(const VOLUME_ID *volume, const char *pat
fileInfo->Attributes = FileAttributes::FileAttributes_Archive;
}

// set the file size
fileInfo->Size = info.st_size;

// no need to set the file name details as managed code already has this info
}

Expand Down
2 changes: 2 additions & 0 deletions targets/netcore/littlefs/littlefs_FS_Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,8 @@ HRESULT LITTLEFS_FS_Driver::GetFileInfo(const VOLUME_ID *volume, const char *pat
&fileInfo->Attributes,
NANO_LITTLEFS_ATTRIBUTE_SIZE);

fileInfo->Size = info.size;

// no need to set the file name details as managed code already has this info
}

Expand Down