diff --git a/CMake/Modules/FindNF_NativeAssemblies.cmake b/CMake/Modules/FindNF_NativeAssemblies.cmake index bf697344d3..db34e38fa3 100644 --- a/CMake/Modules/FindNF_NativeAssemblies.cmake +++ b/CMake/Modules/FindNF_NativeAssemblies.cmake @@ -29,7 +29,6 @@ option(API_System.Device.Pwm "option for System.Devic option(API_System.IO.Ports "option for System.IO.Ports API") option(API_System.Device.Spi "option for System.Device.Spi API") option(API_System.Runtime.Serialization "option for System.Runtime.Serialization API") -option(API_Windows.Storage "option for Windows.Storage") option(API_nanoFramework.Graphics "option for nanoFramework.Graphics") option(API_nanoFramework.Device.Bluetooth "option for nanoFramework.Device.Bluetooth") option(API_System.Device.UsbStream "option for System.Device.UsbStream API") @@ -453,12 +452,6 @@ if(API_System.Device.UsbStream) PerformSettingsForApiEntry("System.Device.UsbStream") endif() -# Windows.Storage -if(API_Windows.Storage) - ##### API name here (doted name) - PerformSettingsForApiEntry("Windows.Storage") -endif() - # Interop assemblies ParseInteropAssemblies() diff --git a/CMake/Modules/FindSystem.IO.FileSystem.cmake b/CMake/Modules/FindSystem.IO.FileSystem.cmake index 21ba465382..0f3316c095 100644 --- a/CMake/Modules/FindSystem.IO.FileSystem.cmake +++ b/CMake/Modules/FindSystem.IO.FileSystem.cmake @@ -8,6 +8,7 @@ set(BASE_PATH_FOR_THIS_MODULE ${BASE_PATH_FOR_CLASS_LIBRARIES_MODULES}/System.IO if(RTOS_FREERTOS_CHECK) set(PROJECT_COMMON_PATH ${PROJECT_SOURCE_DIR}/targets/FreeRTOS/NXP/_common) + set(FATFS_PLATFORM ${PROJECT_SOURCE_DIR}/targets/FreeRTOS/NXP/_FatFs) else() set(PROJECT_COMMON_PATH ${PROJECT_SOURCE_DIR}/targets/${RTOS}/_common) endif() @@ -75,6 +76,7 @@ foreach(SRC_FILE ${System.IO.FileSystem_SRCS}) # FatFs ${CMAKE_SOURCE_DIR}/targets/${RTOS}/_FatFs + ${FATFS_PLATFORM} CMAKE_FIND_ROOT_PATH_BOTH ) diff --git a/CMake/Modules/FindWindows.Storage.cmake b/CMake/Modules/FindWindows.Storage.cmake deleted file mode 100644 index 43d3ce3ce5..0000000000 --- a/CMake/Modules/FindWindows.Storage.cmake +++ /dev/null @@ -1,63 +0,0 @@ -# -# Copyright (c) .NET Foundation and Contributors -# See LICENSE file in the project root for full license information. -# - -include(FetchContent) -FetchContent_GetProperties(fatfs) - -# native code directory -set(BASE_PATH_FOR_THIS_MODULE "${BASE_PATH_FOR_CLASS_LIBRARIES_MODULES}/Windows.Storage") - - -# set include directories -if(RTOS_CHIBIOS_CHECK) - #list(APPEND Windows.Storage_INCLUDE_DIRS ${chibios_SOURCE_DIR}/ext/fatfs/src) - list(APPEND Windows.Storage_INCLUDE_DIRS ${fatfs_SOURCE_DIR}/source) -elseif(RTOS_ESP32_CHECK) - # TODO: this needs to be changed so it's not platform & target dependent -elseif(RTOS_FREERTOS_CHECK) - list(APPEND Windows.Storage_INCLUDE_DIRS ${fatfs_SOURCE_DIR}/source) - # TODO: this needs to be changed so it's not platform & target dependent -endif() - -list(APPEND Windows.Storage_INCLUDE_DIRS ${TARGET_BASE_LOCATION}/Include) -list(APPEND Windows.Storage_INCLUDE_DIRS ${BASE_PATH_FOR_THIS_MODULE}) -list(APPEND Windows.Storage_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/src/Windows.Storage) - -# source files -set(Windows.Storage_SRCS - - win_storage_native_Windows_Storage_FileIO.cpp - win_storage_native_Windows_Storage_StorageFile.cpp - win_storage_native_Windows_Storage_StorageFolder.cpp - win_storage_native_Windows_Storage_StorageProvider.cpp - win_storage_native_Windows_Storage_Devices_SDCard.cpp - win_storage_native.cpp -) - -foreach(SRC_FILE ${Windows.Storage_SRCS}) - - set(Windows.Storage_SRC_FILE SRC_FILE-NOTFOUND) - - find_file(Windows.Storage_SRC_FILE ${SRC_FILE} - PATHS - - ${BASE_PATH_FOR_THIS_MODULE} - ${TARGET_BASE_LOCATION} - ${CMAKE_SOURCE_DIR}/src/Windows.Storage - - CMAKE_FIND_ROOT_PATH_BOTH - ) - - if (BUILD_VERBOSE) - message("${SRC_FILE} >> ${Windows.Storage_SRC_FILE}") - endif() - - list(APPEND Windows.Storage_SOURCES ${Windows.Storage_SRC_FILE}) - -endforeach() - -include(FindPackageHandleStandardArgs) - -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Windows.Storage DEFAULT_MSG Windows.Storage_INCLUDE_DIRS Windows.Storage_SOURCES) diff --git a/CMake/Modules/FreeRTOS_IMXRT10xx_GCC_options.cmake b/CMake/Modules/FreeRTOS_IMXRT10xx_GCC_options.cmake index ffbd38063b..9b145d0812 100644 --- a/CMake/Modules/FreeRTOS_IMXRT10xx_GCC_options.cmake +++ b/CMake/Modules/FreeRTOS_IMXRT10xx_GCC_options.cmake @@ -33,8 +33,6 @@ macro(nf_set_compile_options) # this series has FPU target_compile_definitions(${NFSCO_TARGET} PUBLIC -DPLATFORM_ARM -DCORTEX_USE_FPU=TRUE -DUSE_FPU=TRUE) - # temporarily force inclusion of Windows Storage headers - target_compile_definitions(${NFSCO_TARGET} PUBLIC -DINCLUDE_WINDOWS_STORAGE) endmacro() diff --git a/CMakeLists.txt b/CMakeLists.txt index 4235a14065..f3761d4e27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -309,16 +309,11 @@ if(NF_FEATURE_HAS_SDCARD) # this feature currently is supported only on ChibiOS, iMX.RT FreeRTOS and ESP32 FreeRTOS if(NOT RTOS_CHIBIOS_CHECK AND NOT RTOS_FREERTOS_CHECK AND NOT RTOS_ESP32_CHECK) - message(FATAL_ERROR "Support for SD Card is only available for ChibiOS Cortex-M targets, iMX.RT FreeRTOS and ESP32 targets..") + message(FATAL_ERROR "Support for SD Card is only available for ChibiOS Cortex-M targets, iMX.RT FreeRTOS and ESP32 targets.") endif() - if(RTOS_FREERTOS_CHECK) - # ONLY FOR FREERTOS+NXP force inclusion of Windows.Storage API - set(API_Windows.Storage ON CACHE INTERNAL "Forcing Windows.Storage API option to ON") - else() - # all the others RTOSes: force inclusion of System.IO.FileSystem API - set(API_System.IO.FileSystem ON CACHE INTERNAL "Forcing System.IO.FileSystem API option to ON") - endif() + # all RTOSes: force inclusion of System.IO.FileSystem API + set(API_System.IO.FileSystem ON CACHE INTERNAL "Forcing System.IO.FileSystem API option to ON") message(STATUS "Support for SD Card is included") @@ -668,7 +663,6 @@ if( API_nanoFramework.Device.OneWire OR API_System.Device.Gpio OR API_System.IO.Ports OR API_nanoFramework.Device.Can OR - API_Windows.Storage OR API_System.IO.FileSystem) # these APIs requires nanoFramework.Runtime.Events diff --git a/src/HAL/Include/nanoHAL_System_IO_FileSystem.h b/src/HAL/Include/nanoHAL_System_IO_FileSystem.h index 7d060a2d19..d8a23750aa 100644 --- a/src/HAL/Include/nanoHAL_System_IO_FileSystem.h +++ b/src/HAL/Include/nanoHAL_System_IO_FileSystem.h @@ -48,18 +48,6 @@ typedef enum StorageEventType #define DRIVE_LETTER_LENGTH sizeof(INDEX0_DRIVE_LETTER) #define DRIVE_PATH_LENGTH sizeof(INDEX0_DRIVE_PATH) -///////////////////////////////////////////////////////////////////////////////////////// -// !!! KEEP IN SYNC WITH Windows.Storage.CreationCollisionOption (in managed code) !!! // -///////////////////////////////////////////////////////////////////////////////////////// - -enum CreationCollisionOption -{ - CreationCollisionOption_GenerateUniqueName = 0, - CreationCollisionOption_ReplaceExisting, - CreationCollisionOption_FailIfExists, - CreationCollisionOption_OpenIfExists -}; - #ifdef __cplusplus extern "C" { diff --git a/src/HAL/Include/nanoHAL_Windows_Storage.h b/src/HAL/Include/nanoHAL_Windows_Storage.h deleted file mode 100644 index 37407009ed..0000000000 --- a/src/HAL/Include/nanoHAL_Windows_Storage.h +++ /dev/null @@ -1,74 +0,0 @@ -// -// Copyright (c) .NET Foundation and Contributors -// See LICENSE file in the project root for full license information. -// -#ifndef NANOHAL_WINDOWS_STORAGE_H -#define NANOHAL_WINDOWS_STORAGE_H - -///////////////////////////////////////////////////////////////////////// -// TO BE RENAMED TO SYS.IO.FILESYSTEM after removal of Windows.Storage // -///////////////////////////////////////////////////////////////////////// - -// driver letters and paths -// drive letter for SD Card -#define INDEX0_DRIVE_LETTER "D:" -#define INDEX0_DRIVE_PATH INDEX0_DRIVE_LETTER "\\" -// drive letter for USB mass storage device -#define INDEX1_DRIVE_LETTER "E:" -#define INDEX1_DRIVE_PATH INDEX1_DRIVE_LETTER "\\" -// spare drive letter -#define INDEX2_DRIVE_LETTER "F:" -#define INDEX2_DRIVE_PATH INDEX2_DRIVE_LETTER "\\" -// drive letter for internal drive (SPIFFS) -#define INTERNAL_DRIVE0_LETTER "I:" -#define INTERNAL_DRIVE0_PATH INTERNAL_DRIVE0_LETTER "\\" -// drive letter for second internal drive (SPIFFS) -#define INTERNAL_DRIVE1_LETTER "J:" -#define INTERNAL_DRIVE1_PATH INTERNAL_DRIVE1_LETTER "\\" - -////////////////////////////////////////////////////////////////////////// -// Keep in sync with StorageEventManager.StorageEventType in managed code -// Storage events sub-categories -////////////////////////////////////////////////////////////////////////// -typedef enum StorageEventType -{ - // INVALID - StorageEventType_Invalid = 0x00, - - // removable device inserted - StorageEventType_RemovableDeviceInsertion = 0x01, - - // removable device removed - StorageEventType_RemovableDeviceRemoval = 0x02, - -} StorageEventType; - -// constants to be used throughout the code -#define SUPPORTED_DRIVES_COUNT (2) -#define DRIVE_LETTER_LENGTH sizeof(INDEX0_DRIVE_LETTER) -#define DRIVE_PATH_LENGTH sizeof(INDEX0_DRIVE_PATH) - -///////////////////////////////////////////////////////////////////////////////////////// -// !!! KEEP IN SYNC WITH Windows.Storage.CreationCollisionOption (in managed code) !!! // -///////////////////////////////////////////////////////////////////////////////////////// - -enum CreationCollisionOption -{ - CreationCollisionOption_GenerateUniqueName = 0, - CreationCollisionOption_ReplaceExisting, - CreationCollisionOption_FailIfExists, - CreationCollisionOption_OpenIfExists -}; - -#ifdef __cplusplus -extern "C" -{ -#endif - - void Target_FileSystemInit(void); - -#ifdef __cplusplus -} -#endif - -#endif // NANOHAL_WINDOWS_STORAGE_H diff --git a/src/HAL/Include/nanoHAL_v2.h b/src/HAL/Include/nanoHAL_v2.h index 233a66ef94..46dde0e3a1 100644 --- a/src/HAL/Include/nanoHAL_v2.h +++ b/src/HAL/Include/nanoHAL_v2.h @@ -414,10 +414,6 @@ extern "C" #include #include -#ifdef INCLUDE_WINDOWS_STORAGE -#include -#else #include -#endif #endif // NANOHAL_V2_H diff --git a/src/System.IO.FileSystem/nf_sys_io_filesystem_System_IO_File.cpp b/src/System.IO.FileSystem/nf_sys_io_filesystem_System_IO_File.cpp index 1bb8065dab..863ee56762 100644 --- a/src/System.IO.FileSystem/nf_sys_io_filesystem_System_IO_File.cpp +++ b/src/System.IO.FileSystem/nf_sys_io_filesystem_System_IO_File.cpp @@ -6,7 +6,6 @@ #include "nf_sys_io_filesystem.h" #include -#include extern SYSTEMTIME GetDateTime(uint16_t date, uint16_t time); extern void CombinePathAndName(char *outpath, const char *path1, const char *path2); diff --git a/src/Windows.Storage/Windows.Storage.vcxproj b/src/Windows.Storage/Windows.Storage.vcxproj deleted file mode 100644 index e977a02ef9..0000000000 --- a/src/Windows.Storage/Windows.Storage.vcxproj +++ /dev/null @@ -1,166 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - - - - - - - - - - - - {3cae286f-0ef8-45e4-8111-afa0aa9282b4} - Win32Proj - Windows.Storage - 10.0 - - - - StaticLibrary - true - v143 - Unicode - - - StaticLibrary - false - v143 - true - Unicode - - - StaticLibrary - true - v143 - Unicode - - - StaticLibrary - false - v143 - true - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - $(BinDir) - $(IntDir) - - - $(BinDir) - $(IntDir) - - - $(BinDir) - $(IntDir) - - - $(BinDir) - $(IntDir) - - - - - - Level3 - Disabled - _DEBUG;DEBUG;_LIB;%(PreprocessorDefinitions) - ..\..\targets\win32\Include;..\Include;..\CLR\Include;..\CorLib;..\HAL\Include;..\PAL\Include;%(AdditionalIncludeDirectories) - - - Windows - - - - - - - Level3 - Disabled - _DEBUG;DEBUG;_LIB;%(PreprocessorDefinitions) - ..\..\targets\win32\Include;..\Include;..\CLR\Include;..\CorLib;..\HAL\Include;..\PAL\Include;%(AdditionalIncludeDirectories) - - - Windows - - - - - Level3 - - - MaxSpeed - true - true - NDEBUG;_LIB;%(PreprocessorDefinitions) - ..\..\targets\win32\Include;..\Include;..\CLR\Include;..\CorLib;..\HAL\Include;..\PAL\Include;%(AdditionalIncludeDirectories) - - - Windows - true - true - - - - - Level3 - - - MaxSpeed - true - true - NDEBUG;_LIB;%(PreprocessorDefinitions) - ..\..\targets\win32\Include;..\Include;..\CLR\Include;..\CorLib;..\HAL\Include;..\PAL\Include;%(AdditionalIncludeDirectories) - - - Windows - true - true - - - - - - diff --git a/src/Windows.Storage/Windows.Storage.vcxproj.filters b/src/Windows.Storage/Windows.Storage.vcxproj.filters deleted file mode 100644 index 10064caf71..0000000000 --- a/src/Windows.Storage/Windows.Storage.vcxproj.filters +++ /dev/null @@ -1,42 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - \ No newline at end of file diff --git a/src/Windows.Storage/win_storage_native.cpp b/src/Windows.Storage/win_storage_native.cpp deleted file mode 100644 index 56952ffb72..0000000000 --- a/src/Windows.Storage/win_storage_native.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// -// Copyright (c) .NET Foundation and Contributors -// See LICENSE file in the project root for full license information. -// - -#include "win_storage_native.h" - -// clang-format off - -static const CLR_RT_MethodHandler method_lookup[] = -{ - NULL, - NULL, - NULL, - NULL, - Library_win_storage_native_Windows_Storage_Devices_SDCard::MountMMCNative___STATIC__VOID__BOOLEAN, - Library_win_storage_native_Windows_Storage_Devices_SDCard::MountSpiNative___STATIC__VOID__I4__I4, - Library_win_storage_native_Windows_Storage_Devices_SDCard::UnmountNative___STATIC__VOID, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_win_storage_native_Windows_Storage_FileIO::WriteBytes___STATIC__VOID__WindowsStorageIStorageFile__SZARRAY_U1, - Library_win_storage_native_Windows_Storage_FileIO::WriteText___STATIC__VOID__WindowsStorageIStorageFile__STRING, - Library_win_storage_native_Windows_Storage_FileIO::ReadBufferNative___STATIC__VOID__WindowsStorageIStorageFile__BYREF_SZARRAY_U1, - Library_win_storage_native_Windows_Storage_FileIO::ReadTextNative___STATIC__VOID__WindowsStorageIStorageFile__BYREF_STRING, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_win_storage_native_Windows_Storage_StorageFile::DeleteFileNative___VOID, - Library_win_storage_native_Windows_Storage_StorageFile::RenameFileNative___VOID__STRING, - NULL, - NULL, - Library_win_storage_native_Windows_Storage_StorageFile::GetFileFromPathNative___STATIC__WindowsStorageStorageFile__STRING__STRING, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Library_win_storage_native_Windows_Storage_StorageFolder::GetRemovableStorageFoldersNative___SZARRAY_WindowsStorageStorageFolder, - Library_win_storage_native_Windows_Storage_StorageFolder::GetInternalStorageFoldersNative___SZARRAY_WindowsStorageStorageFolder, - Library_win_storage_native_Windows_Storage_StorageFolder::GetStorageFoldersNative___SZARRAY_WindowsStorageStorageFolder, - Library_win_storage_native_Windows_Storage_StorageFolder::GetStorageFilesNative___SZARRAY_WindowsStorageStorageFile__U4__U4, - Library_win_storage_native_Windows_Storage_StorageFolder::CreateFileNative___WindowsStorageStorageFile__STRING__U4, - Library_win_storage_native_Windows_Storage_StorageFolder::CreateFolderNative___WindowsStorageStorageFolder__STRING__U4, - Library_win_storage_native_Windows_Storage_StorageFolder::DeleteFolderNative___VOID, - Library_win_storage_native_Windows_Storage_StorageFolder::RenameFolderNative___VOID__STRING, - Library_win_storage_native_Windows_Storage_StorageFolder::GetFolderNative___WindowsStorageStorageFolder__STRING, - NULL, - NULL, - Library_win_storage_native_Windows_Storage_StorageProvider::FormatVolume___VOID__STRING, - NULL, -}; - -const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_Windows_Storage = -{ - "Windows.Storage", - 0xF0C37E1B, - method_lookup, - { 100, 0, 3, 0 } -}; - -// clang-format on diff --git a/src/Windows.Storage/win_storage_native.h b/src/Windows.Storage/win_storage_native.h deleted file mode 100644 index 2e1816fb20..0000000000 --- a/src/Windows.Storage/win_storage_native.h +++ /dev/null @@ -1,109 +0,0 @@ -// -// Copyright (c) .NET Foundation and Contributors -// See LICENSE file in the project root for full license information. -// - -#ifndef WIN_STORAGE_NATIVE_H -#define WIN_STORAGE_NATIVE_H - -#include -#include - -typedef enum __nfpack KnownFolderId -{ - KnownFolderId_RemovableDevices = 10, - KnownFolderId_InternalDevices = 14, -} KnownFolderId; - -struct Library_win_storage_native_Windows_Storage_Devices_SDCard -{ - static const int FIELD_STATIC___mounted = 0; - - NANOCLR_NATIVE_DECLARE(MountMMCNative___STATIC__VOID__BOOLEAN); - NANOCLR_NATIVE_DECLARE(MountSpiNative___STATIC__VOID__I4__I4); - NANOCLR_NATIVE_DECLARE(UnmountNative___STATIC__VOID); - - //--// -}; - -struct Library_win_storage_native_Windows_Storage_FileIO -{ - NANOCLR_NATIVE_DECLARE(WriteBytes___STATIC__VOID__WindowsStorageIStorageFile__SZARRAY_U1); - NANOCLR_NATIVE_DECLARE(WriteText___STATIC__VOID__WindowsStorageIStorageFile__STRING); - NANOCLR_NATIVE_DECLARE(ReadBufferNative___STATIC__VOID__WindowsStorageIStorageFile__BYREF_SZARRAY_U1); - NANOCLR_NATIVE_DECLARE(ReadTextNative___STATIC__VOID__WindowsStorageIStorageFile__BYREF_STRING); - - //--// -}; - -struct Library_win_storage_native_Windows_Storage_RemovableDeviceEventArgs -{ - static const int FIELD___path = 1; - static const int FIELD___event = 2; - - //--// -}; - -struct Library_win_storage_native_Windows_Storage_StorageEventManager -{ - static const int FIELD_STATIC__RemovableDeviceInserted = 1; - static const int FIELD_STATIC__RemovableDeviceRemoved = 2; - - //--// -}; - -struct Library_win_storage_native_Windows_Storage_StorageEventManager__StorageEvent -{ - static const int FIELD__EventType = 3; - static const int FIELD__DriveIndex = 4; - static const int FIELD__Time = 5; - - //--// -}; - -struct Library_win_storage_native_Windows_Storage_StorageFile -{ - static const int FIELD___dateCreated = 1; - static const int FIELD___name = 2; - static const int FIELD___path = 3; - - NANOCLR_NATIVE_DECLARE(DeleteFileNative___VOID); - NANOCLR_NATIVE_DECLARE(RenameFileNative___VOID__STRING); - NANOCLR_NATIVE_DECLARE(GetFileFromPathNative___STATIC__WindowsStorageStorageFile__STRING__STRING); - - //--// -}; - -struct Library_win_storage_native_Windows_Storage_StorageFolder -{ - static const int FIELD___knownFolderId = 1; - static const int FIELD___dateCreated = 2; - static const int FIELD___name = 3; - static const int FIELD___path = 4; - - NANOCLR_NATIVE_DECLARE(GetRemovableStorageFoldersNative___SZARRAY_WindowsStorageStorageFolder); - NANOCLR_NATIVE_DECLARE(GetInternalStorageFoldersNative___SZARRAY_WindowsStorageStorageFolder); - NANOCLR_NATIVE_DECLARE(GetStorageFoldersNative___SZARRAY_WindowsStorageStorageFolder); - NANOCLR_NATIVE_DECLARE(GetStorageFilesNative___SZARRAY_WindowsStorageStorageFile__U4__U4); - NANOCLR_NATIVE_DECLARE(CreateFileNative___WindowsStorageStorageFile__STRING__U4); - NANOCLR_NATIVE_DECLARE(CreateFolderNative___WindowsStorageStorageFolder__STRING__U4); - NANOCLR_NATIVE_DECLARE(DeleteFolderNative___VOID); - NANOCLR_NATIVE_DECLARE(RenameFolderNative___VOID__STRING); - NANOCLR_NATIVE_DECLARE(GetFolderNative___WindowsStorageStorageFolder__STRING); - - //--// -}; - -struct Library_win_storage_native_Windows_Storage_StorageProvider -{ - static const int FIELD___displayName = 1; - static const int FIELD___id = 2; - - NANOCLR_NATIVE_DECLARE(FormatVolume___VOID__STRING); - - //--// -}; - -extern const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_Windows_Storage; - -#endif // WIN_STORAGE_NATIVE_H diff --git a/src/Windows.Storage/win_storage_native_Windows_Storage_Devices_SDCard_stubs.cpp b/src/Windows.Storage/win_storage_native_Windows_Storage_Devices_SDCard_stubs.cpp deleted file mode 100644 index dd59c79ce4..0000000000 --- a/src/Windows.Storage/win_storage_native_Windows_Storage_Devices_SDCard_stubs.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// -// Copyright (c) .NET Foundation and Contributors -// See LICENSE file in the project root for full license information. -// - -#include "win_storage_native.h" - -HRESULT Library_win_storage_native_Windows_Storage_Devices_SDCard::MountMMCNative___STATIC__VOID__BOOLEAN( - CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - NANOCLR_SET_AND_LEAVE(stack.NotImplementedStub()); - - NANOCLR_NOCLEANUP(); -} - -HRESULT Library_win_storage_native_Windows_Storage_Devices_SDCard::MountSpiNative___STATIC__VOID__I4__I4( - CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - NANOCLR_SET_AND_LEAVE(stack.NotImplementedStub()); - - NANOCLR_NOCLEANUP(); -} - -HRESULT Library_win_storage_native_Windows_Storage_Devices_SDCard::UnmountNative___STATIC__VOID( - CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - NANOCLR_SET_AND_LEAVE(stack.NotImplementedStub()); - - NANOCLR_NOCLEANUP(); -} diff --git a/src/Windows.Storage/win_storage_native_Windows_Storage_FileIO_stubs.cpp b/src/Windows.Storage/win_storage_native_Windows_Storage_FileIO_stubs.cpp deleted file mode 100644 index 0962187277..0000000000 --- a/src/Windows.Storage/win_storage_native_Windows_Storage_FileIO_stubs.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// -// Copyright (c) .NET Foundation and Contributors -// See LICENSE file in the project root for full license information. -// - -#include "win_storage_native.h" - -HRESULT Library_win_storage_native_Windows_Storage_FileIO:: - WriteBytes___STATIC__VOID__WindowsStorageIStorageFile__SZARRAY_U1(CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - NANOCLR_SET_AND_LEAVE(stack.NotImplementedStub()); - - NANOCLR_NOCLEANUP(); -} - -HRESULT Library_win_storage_native_Windows_Storage_FileIO::WriteText___STATIC__VOID__WindowsStorageIStorageFile__STRING( - CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - NANOCLR_SET_AND_LEAVE(stack.NotImplementedStub()); - - NANOCLR_NOCLEANUP(); -} - -HRESULT Library_win_storage_native_Windows_Storage_FileIO:: - ReadBufferNative___STATIC__VOID__WindowsStorageIStorageFile__BYREF_SZARRAY_U1(CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - NANOCLR_SET_AND_LEAVE(stack.NotImplementedStub()); - - NANOCLR_NOCLEANUP(); -} - -HRESULT Library_win_storage_native_Windows_Storage_FileIO:: - ReadTextNative___STATIC__VOID__WindowsStorageIStorageFile__BYREF_STRING(CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - NANOCLR_SET_AND_LEAVE(stack.NotImplementedStub()); - - NANOCLR_NOCLEANUP(); -} diff --git a/src/Windows.Storage/win_storage_native_Windows_Storage_StorageFile_stubs.cpp b/src/Windows.Storage/win_storage_native_Windows_Storage_StorageFile_stubs.cpp deleted file mode 100644 index 1d7faac68e..0000000000 --- a/src/Windows.Storage/win_storage_native_Windows_Storage_StorageFile_stubs.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// -// Copyright (c) .NET Foundation and Contributors -// See LICENSE file in the project root for full license information. -// - -#include "win_storage_native.h" - -HRESULT Library_win_storage_native_Windows_Storage_StorageFile::DeleteFileNative___VOID(CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - NANOCLR_SET_AND_LEAVE(stack.NotImplementedStub()); - - NANOCLR_NOCLEANUP(); -} - -HRESULT Library_win_storage_native_Windows_Storage_StorageFile::RenameFileNative___VOID__STRING( - CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - NANOCLR_SET_AND_LEAVE(stack.NotImplementedStub()); - - NANOCLR_NOCLEANUP(); -} - -HRESULT Library_win_storage_native_Windows_Storage_StorageFile:: - GetFileFromPathNative___STATIC__WindowsStorageStorageFile__STRING__STRING(CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - NANOCLR_SET_AND_LEAVE(stack.NotImplementedStub()); - - NANOCLR_NOCLEANUP(); -} diff --git a/src/Windows.Storage/win_storage_native_Windows_Storage_StorageFolder_stubs.cpp b/src/Windows.Storage/win_storage_native_Windows_Storage_StorageFolder_stubs.cpp deleted file mode 100644 index eae2b52650..0000000000 --- a/src/Windows.Storage/win_storage_native_Windows_Storage_StorageFolder_stubs.cpp +++ /dev/null @@ -1,95 +0,0 @@ -// -// Copyright (c) .NET Foundation and Contributors -// See LICENSE file in the project root for full license information. -// - -#include "win_storage_native.h" - -HRESULT Library_win_storage_native_Windows_Storage_StorageFolder:: - GetRemovableStorageFoldersNative___SZARRAY_WindowsStorageStorageFolder(CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - NANOCLR_SET_AND_LEAVE(stack.NotImplementedStub()); - - NANOCLR_NOCLEANUP(); -} - -HRESULT Library_win_storage_native_Windows_Storage_StorageFolder:: - GetInternalStorageFoldersNative___SZARRAY_WindowsStorageStorageFolder(CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - NANOCLR_SET_AND_LEAVE(stack.NotImplementedStub()); - - NANOCLR_NOCLEANUP(); -} - -HRESULT Library_win_storage_native_Windows_Storage_StorageFolder:: - GetStorageFoldersNative___SZARRAY_WindowsStorageStorageFolder(CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - NANOCLR_SET_AND_LEAVE(stack.NotImplementedStub()); - - NANOCLR_NOCLEANUP(); -} - -HRESULT Library_win_storage_native_Windows_Storage_StorageFolder:: - GetStorageFilesNative___SZARRAY_WindowsStorageStorageFile__U4__U4(CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - NANOCLR_SET_AND_LEAVE(stack.NotImplementedStub()); - - NANOCLR_NOCLEANUP(); -} - -HRESULT Library_win_storage_native_Windows_Storage_StorageFolder:: - CreateFileNative___WindowsStorageStorageFile__STRING__U4(CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - NANOCLR_SET_AND_LEAVE(stack.NotImplementedStub()); - - NANOCLR_NOCLEANUP(); -} - -HRESULT Library_win_storage_native_Windows_Storage_StorageFolder:: - CreateFolderNative___WindowsStorageStorageFolder__STRING__U4(CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - NANOCLR_SET_AND_LEAVE(stack.NotImplementedStub()); - - NANOCLR_NOCLEANUP(); -} - -HRESULT Library_win_storage_native_Windows_Storage_StorageFolder::DeleteFolderNative___VOID(CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - NANOCLR_SET_AND_LEAVE(stack.NotImplementedStub()); - - NANOCLR_NOCLEANUP(); -} - -HRESULT Library_win_storage_native_Windows_Storage_StorageFolder::RenameFolderNative___VOID__STRING( - CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - NANOCLR_SET_AND_LEAVE(stack.NotImplementedStub()); - - NANOCLR_NOCLEANUP(); -} - -HRESULT Library_win_storage_native_Windows_Storage_StorageFolder::GetFolderNative___WindowsStorageStorageFolder__STRING( - CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - NANOCLR_SET_AND_LEAVE(stack.NotImplementedStub()); - - NANOCLR_NOCLEANUP(); -} diff --git a/src/Windows.Storage/win_storage_native_Windows_Storage_StorageProvider_stubs.cpp b/src/Windows.Storage/win_storage_native_Windows_Storage_StorageProvider_stubs.cpp deleted file mode 100644 index c7a64649ad..0000000000 --- a/src/Windows.Storage/win_storage_native_Windows_Storage_StorageProvider_stubs.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) .NET Foundation and Contributors -// See LICENSE file in the project root for full license information. -// - -#include "win_storage_native.h" - -HRESULT Library_win_storage_native_Windows_Storage_StorageProvider::FormatVolume___VOID__STRING( - CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - NANOCLR_SET_AND_LEAVE(stack.NotImplementedStub()); - - NANOCLR_NOCLEANUP(); -} diff --git a/targets/AzureRTOS/ST/ORGPAL_PALTHREE/target_windows_storage_config.h b/targets/AzureRTOS/ST/ORGPAL_PALTHREE/target_storage_config.h similarity index 62% rename from targets/AzureRTOS/ST/ORGPAL_PALTHREE/target_windows_storage_config.h rename to targets/AzureRTOS/ST/ORGPAL_PALTHREE/target_storage_config.h index 7bc1934cbc..170480e58a 100644 --- a/targets/AzureRTOS/ST/ORGPAL_PALTHREE/target_windows_storage_config.h +++ b/targets/AzureRTOS/ST/ORGPAL_PALTHREE/target_storage_config.h @@ -3,11 +3,16 @@ // See LICENSE file in the project root for full license information. // +#ifndef _TARGET_STORAGE_CONFIG_H_ +#define _TARGET_STORAGE_CONFIG_H_ + // the following macro maps the SD card driver #define SD_CARD_DRIVER SDCD1 -// maps the SD Card detect GPIO definition (in Target_Windows_Storage.c) to board GPIO line (in board.h) +// maps the SD Card detect GPIO definition (in target config storage) to board GPIO line (in board.h) #define SDCARD_LINE_DETECT LINE_SD_CARD_DETECT // the following macro maps the USB mass storage device driver #define USB_MSD_DRIVER USBHD2 + +#endif // _TARGET_STORAGE_CONFIG_H_ diff --git a/targets/AzureRTOS/_common/include/Target_Windows_Storage.h b/targets/AzureRTOS/_common/include/Target_Windows_Storage.h deleted file mode 100644 index 7a235c1dcf..0000000000 --- a/targets/AzureRTOS/_common/include/Target_Windows_Storage.h +++ /dev/null @@ -1,9 +0,0 @@ -// -// Copyright (c) .NET Foundation and Contributors -// See LICENSE file in the project root for full license information. -// - -#ifndef _TARGET_WINDOWS_STORAGE_H_ -#define _TARGET_WINDOWS_STORAGE_H_ - -#endif //_TARGET_WINDOWS_STORAGE_H_ diff --git a/targets/ChibiOS/ORGPAL_PALTHREE/target_FileSystem.cpp b/targets/ChibiOS/ORGPAL_PALTHREE/target_FileSystem.cpp index a158f1cc6d..b7bfef7bb1 100644 --- a/targets/ChibiOS/ORGPAL_PALTHREE/target_FileSystem.cpp +++ b/targets/ChibiOS/ORGPAL_PALTHREE/target_FileSystem.cpp @@ -18,7 +18,7 @@ extern FILESYSTEM_DRIVER_INTERFACE g_FATFS_FILE_SYSTEM_DriverInterface; extern STREAM_DRIVER_INTERFACE g_LITTLEFS_STREAM_DriverInterface; #if HAL_USE_SDC -#include +#include extern "C" void SdCardDetectCallback(void *arg); #endif diff --git a/targets/ChibiOS/ORGPAL_PALX/target_windows_storage_config.h b/targets/ChibiOS/ORGPAL_PALTHREE/target_storage_config.h similarity index 62% rename from targets/ChibiOS/ORGPAL_PALX/target_windows_storage_config.h rename to targets/ChibiOS/ORGPAL_PALTHREE/target_storage_config.h index 7bc1934cbc..776135b6f1 100644 --- a/targets/ChibiOS/ORGPAL_PALX/target_windows_storage_config.h +++ b/targets/ChibiOS/ORGPAL_PALTHREE/target_storage_config.h @@ -3,11 +3,16 @@ // See LICENSE file in the project root for full license information. // +#ifndef _TARGET_STORAGE_CONFIG_H_ +#define _TARGET_STORAGE_CONFIG_H_ + // the following macro maps the SD card driver #define SD_CARD_DRIVER SDCD1 -// maps the SD Card detect GPIO definition (in Target_Windows_Storage.c) to board GPIO line (in board.h) +// maps the SD Card detect GPIO definition (target storage config) to board GPIO line (in board.h) #define SDCARD_LINE_DETECT LINE_SD_CARD_DETECT // the following macro maps the USB mass storage device driver #define USB_MSD_DRIVER USBHD2 + +#endif // _TARGET_STORAGE_CONFIG_H_ diff --git a/targets/ChibiOS/ORGPAL_PALX/target_FileSystem.cpp b/targets/ChibiOS/ORGPAL_PALX/target_FileSystem.cpp index 102fcd3049..fcc2f6df56 100644 --- a/targets/ChibiOS/ORGPAL_PALX/target_FileSystem.cpp +++ b/targets/ChibiOS/ORGPAL_PALX/target_FileSystem.cpp @@ -18,7 +18,7 @@ extern FILESYSTEM_DRIVER_INTERFACE g_FATFS_FILE_SYSTEM_DriverInterface; extern STREAM_DRIVER_INTERFACE g_LITTLEFS_STREAM_DriverInterface; #if HAL_USE_SDC -#include +#include extern "C" void SdCardDetectCallback(void *arg); #endif diff --git a/targets/ChibiOS/ORGPAL_PALTHREE/target_windows_storage_config.h b/targets/ChibiOS/ORGPAL_PALX/target_storage_config.h similarity index 62% rename from targets/ChibiOS/ORGPAL_PALTHREE/target_windows_storage_config.h rename to targets/ChibiOS/ORGPAL_PALX/target_storage_config.h index 7bc1934cbc..776135b6f1 100644 --- a/targets/ChibiOS/ORGPAL_PALTHREE/target_windows_storage_config.h +++ b/targets/ChibiOS/ORGPAL_PALX/target_storage_config.h @@ -3,11 +3,16 @@ // See LICENSE file in the project root for full license information. // +#ifndef _TARGET_STORAGE_CONFIG_H_ +#define _TARGET_STORAGE_CONFIG_H_ + // the following macro maps the SD card driver #define SD_CARD_DRIVER SDCD1 -// maps the SD Card detect GPIO definition (in Target_Windows_Storage.c) to board GPIO line (in board.h) +// maps the SD Card detect GPIO definition (target storage config) to board GPIO line (in board.h) #define SDCARD_LINE_DETECT LINE_SD_CARD_DETECT // the following macro maps the USB mass storage device driver #define USB_MSD_DRIVER USBHD2 + +#endif // _TARGET_STORAGE_CONFIG_H_ diff --git a/targets/ChibiOS/ST_STM32F769I_DISCOVERY/target_windows_storage_config.h b/targets/ChibiOS/ST_STM32F769I_DISCOVERY/target_storage_config.h similarity index 52% rename from targets/ChibiOS/ST_STM32F769I_DISCOVERY/target_windows_storage_config.h rename to targets/ChibiOS/ST_STM32F769I_DISCOVERY/target_storage_config.h index 4974ef05fd..44498689ec 100644 --- a/targets/ChibiOS/ST_STM32F769I_DISCOVERY/target_windows_storage_config.h +++ b/targets/ChibiOS/ST_STM32F769I_DISCOVERY/target_storage_config.h @@ -3,8 +3,13 @@ // See LICENSE file in the project root for full license information. // +#ifndef _TARGET_STORAGE_CONFIG_H_ +#define _TARGET_STORAGE_CONFIG_H_ + // maps the SD Card driver #define SD_CARD_DRIVER SDCD2 -// maps the SD Card detect GPIO definition (in Target_Windows_Storage.c) to board GPIO line (in board.h) +// maps the SD Card detect GPIO definition (target storage config) to board GPIO line (in board.h) #define SDCARD_LINE_DETECT LINE_SD_DETECT + +#endif // _TARGET_STORAGE_CONFIG_H_ diff --git a/targets/ChibiOS/_common/Target_System_IO_FileSystem.c b/targets/ChibiOS/_common/Target_System_IO_FileSystem.c index 6da207a831..e1bc6688df 100644 --- a/targets/ChibiOS/_common/Target_System_IO_FileSystem.c +++ b/targets/ChibiOS/_common/Target_System_IO_FileSystem.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/targets/ESP32/_common/Target_System_IO_FileSystem.c b/targets/ESP32/_common/Target_System_IO_FileSystem.c index c0a00af20a..baa128af58 100644 --- a/targets/ESP32/_common/Target_System_IO_FileSystem.c +++ b/targets/ESP32/_common/Target_System_IO_FileSystem.c @@ -36,7 +36,7 @@ #include -#include +#include #include #if (HAL_USE_SDC == TRUE) diff --git a/targets/FreeRTOS/NXP/NXP_MIMXRT1060_EVK/CMakePresets.json b/targets/FreeRTOS/NXP/NXP_MIMXRT1060_EVK/CMakePresets.json index 307bbfaac0..6ed1d80f7c 100644 --- a/targets/FreeRTOS/NXP/NXP_MIMXRT1060_EVK/CMakePresets.json +++ b/targets/FreeRTOS/NXP/NXP_MIMXRT1060_EVK/CMakePresets.json @@ -25,7 +25,7 @@ "LWIP_VERSION": "", "NF_BUILD_RTM": "OFF", "NF_FEATURE_DEBUGGER": "ON", - "NF_FEATURE_HAS_SDCARD": "ON", + "NF_FEATURE_HAS_SDCARD": "OFF", "NF_FEATURE_RTC": "ON", "NF_FEATURE_HAS_CONFIG_BLOCK": "ON", "NF_SECURITY_MBEDTLS": "OFF", diff --git a/targets/FreeRTOS/NXP/NXP_MIMXRT1060_EVK/nanoCLR/main.c b/targets/FreeRTOS/NXP/NXP_MIMXRT1060_EVK/nanoCLR/main.c index 3b24eecd10..756df36803 100644 --- a/targets/FreeRTOS/NXP/NXP_MIMXRT1060_EVK/nanoCLR/main.c +++ b/targets/FreeRTOS/NXP/NXP_MIMXRT1060_EVK/nanoCLR/main.c @@ -20,7 +20,7 @@ #include "Target_BlockStorage_iMXRTFlashDriver.h" #include "CLR_Startup_Thread.h" -extern void SdCardThread(void * argument); +// TODO extern void SdCardThread(void * argument); // configure heap memory __attribute__((section(".noinit.$SRAM_OC.ucHeap"))) uint8_t ucHeap[configTOTAL_HEAP_SIZE]; @@ -40,10 +40,11 @@ int main(void) xTaskCreate(ReceiverThread, "ReceiverThread", 2048, NULL, configMAX_PRIORITIES - 1, NULL); xTaskCreate(CLRStartupThread, "CLRStartupThread", 8192, NULL, configMAX_PRIORITIES - 2, NULL); - xTaskCreate(SdCardThread, "SDCardThread", configMINIMAL_STACK_SIZE + 100, NULL, configMAX_PRIORITIES - 2, NULL); + // TODO xTaskCreate(SdCardThread, "SDCardThread", configMINIMAL_STACK_SIZE + 100, NULL, configMAX_PRIORITIES - 2, + // NULL); vTaskStartScheduler(); for (;;) ; return 0; -} \ No newline at end of file +} diff --git a/targets/FreeRTOS/NXP/NXP_MIMXRT1060_EVK/target_FileSystem.cpp b/targets/FreeRTOS/NXP/NXP_MIMXRT1060_EVK/target_FileSystem.cpp index fb9db56c94..e22cf48e1c 100644 --- a/targets/FreeRTOS/NXP/NXP_MIMXRT1060_EVK/target_FileSystem.cpp +++ b/targets/FreeRTOS/NXP/NXP_MIMXRT1060_EVK/target_FileSystem.cpp @@ -18,7 +18,7 @@ // extern FILESYSTEM_DRIVER_INTERFACE g_FATFS_FILE_SYSTEM_DriverInterface; // #if HAL_USE_SDC -// #include +// #include // extern "C" void SdCardDetectCallback(void *arg); // #endif @@ -65,8 +65,7 @@ void FS_AddVolumes() void FS_MountRemovableVolumes() { -// #if HAL_USE_SDC -// SdCardDetectCallback(&SD_CARD_DRIVER); -// #endif - + // #if HAL_USE_SDC + // SdCardDetectCallback(&SD_CARD_DRIVER); + // #endif } diff --git a/targets/FreeRTOS/NXP/_fatfs/diskio.c b/targets/FreeRTOS/NXP/_FatFs/diskio.c similarity index 100% rename from targets/FreeRTOS/NXP/_fatfs/diskio.c rename to targets/FreeRTOS/NXP/_FatFs/diskio.c diff --git a/targets/win32/Include/Target_Windows_Storage.h b/targets/FreeRTOS/NXP/_FatFs/fatfs_FS_Driver.cpp similarity index 55% rename from targets/win32/Include/Target_Windows_Storage.h rename to targets/FreeRTOS/NXP/_FatFs/fatfs_FS_Driver.cpp index fb818bf872..5e883c48b8 100644 --- a/targets/win32/Include/Target_Windows_Storage.h +++ b/targets/FreeRTOS/NXP/_FatFs/fatfs_FS_Driver.cpp @@ -3,7 +3,4 @@ // See LICENSE file in the project root for full license information. // -#ifndef TARGET_WINDOWS_STORAGE_H -#define TARGET_WINDOWS_STORAGE_H - -#endif //TARGET_WINDOWS_STORAGE_H +// TODO: complete migration to System.IO.FileSystem diff --git a/targets/FreeRTOS/NXP/_FatFs/fatfs_FS_Driver.h b/targets/FreeRTOS/NXP/_FatFs/fatfs_FS_Driver.h new file mode 100644 index 0000000000..d73e53ee59 --- /dev/null +++ b/targets/FreeRTOS/NXP/_FatFs/fatfs_FS_Driver.h @@ -0,0 +1,15 @@ +// +// Copyright (c) .NET Foundation and Contributors +// See LICENSE file in the project root for full license information. +// + +#ifndef FATFS_FS_DRIVER_H +#define FATFS_FS_DRIVER_H + +#include +#include +#include + +// TODO: complete migration to System.IO.FileSystem + +#endif // FATFS_FS_DRIVER_H diff --git a/targets/FreeRTOS/NXP/_fatfs/ffconf.h b/targets/FreeRTOS/NXP/_FatFs/ffconf.h similarity index 100% rename from targets/FreeRTOS/NXP/_fatfs/ffconf.h rename to targets/FreeRTOS/NXP/_FatFs/ffconf.h diff --git a/targets/FreeRTOS/NXP/_fatfs/ffsystem.c b/targets/FreeRTOS/NXP/_FatFs/ffsystem.c similarity index 100% rename from targets/FreeRTOS/NXP/_fatfs/ffsystem.c rename to targets/FreeRTOS/NXP/_FatFs/ffsystem.c diff --git a/targets/FreeRTOS/NXP/_fatfs/fsl_sd_disk.c b/targets/FreeRTOS/NXP/_FatFs/fsl_sd_disk.c similarity index 100% rename from targets/FreeRTOS/NXP/_fatfs/fsl_sd_disk.c rename to targets/FreeRTOS/NXP/_FatFs/fsl_sd_disk.c diff --git a/targets/FreeRTOS/NXP/_fatfs/fsl_sd_disk.h b/targets/FreeRTOS/NXP/_FatFs/fsl_sd_disk.h similarity index 100% rename from targets/FreeRTOS/NXP/_fatfs/fsl_sd_disk.h rename to targets/FreeRTOS/NXP/_FatFs/fsl_sd_disk.h diff --git a/targets/FreeRTOS/NXP/_common/CMakeLists.txt b/targets/FreeRTOS/NXP/_common/CMakeLists.txt index 9b5b05a4e9..95bdcb2521 100644 --- a/targets/FreeRTOS/NXP/_common/CMakeLists.txt +++ b/targets/FreeRTOS/NXP/_common/CMakeLists.txt @@ -83,11 +83,6 @@ if(NF_FEATURE_HAS_ACCESSIBLE_STORAGE) list(APPEND TARGET_NXP_COMMON_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/targetHAL_StorageOperation.cpp) endif() -# have to include the Win.Storage target for NXP until it's completely migrated to the new file system -list(APPEND TARGET_NXP_COMMON_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/Target_Windows_Storage.c -) - # List of the required FatFs include files. list(APPEND TARGET_NXP_COMMON_INCLUDE_DIRS ${fatfs_SOURCE_DIR}/source) list(APPEND TARGET_NXP_COMMON_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/targets/FreeRTOS/NXP/_fatfs) diff --git a/targets/FreeRTOS/NXP/_common/Target_System_IO_FileSystem.c b/targets/FreeRTOS/NXP/_common/Target_System_IO_FileSystem.c index 1291f1daea..2906f1262f 100644 --- a/targets/FreeRTOS/NXP/_common/Target_System_IO_FileSystem.c +++ b/targets/FreeRTOS/NXP/_common/Target_System_IO_FileSystem.c @@ -12,3 +12,138 @@ extern void FS_UnmountVolume(const char *rootName); // need to declare this here as extern extern void PostManagedEvent(uint8_t category, uint8_t subCategory, uint16_t data1, uint32_t data2); + +// code ported from old Target_Windows_Storage.c +// TODO: complete migration to System.IO.FileSystem +// // #include "fsl_sd.h" + +// // // need to declare this here as extern +// // extern void PostManagedEvent(uint8_t category, uint8_t subCategory, uint16_t data1, uint32_t data2); + +// // #define SD_CARD_DRIVE_INDEX "0" +// // #define SD_CARD_DRIVE_INDEX_NUMERIC (0) + +// // /////////////////////////////////////////// +// // // code specific to SD Card + +// // // FS for SD Card mounted and ready +// // bool sdCardFileSystemReady; + +// // static FATFS sdCard_FS; + +// // /*! +// // * call back function for SD card detect. +// // * +// // * @param isInserted true, indicate the card is insert. +// // * false, indicate the card is remove. +// // * @param userData +// // */ +// // static void SDCARD_DetectCallBack(bool isInserted, void *userData); + +// // /*! Card descriptor. */ +// // sd_card_t g_sd; + +// // /*! SDMMC host detect card configuration */ +// // static const sdmmchost_detect_card_t s_sdCardDetect = { +// // #ifndef BOARD_SD_DETECT_TYPE +// // .cdType = kSDMMCHOST_DetectCardByGpioCD, +// // #else +// // .cdType = BOARD_SD_DETECT_TYPE, +// // #endif +// // .cdTimeOut_ms = (~0U), +// // .cardInserted = SDCARD_DetectCallBack, +// // .cardRemoved = SDCARD_DetectCallBack, +// // }; + +// // /*! SD card detect flag */ +// // static bool s_cardInserted = false; +// // /*! Card semaphore */ +// // static SemaphoreHandle_t s_CardDetectSemaphore = NULL; + +// // static void SDCARD_DetectCallBack(bool isInserted, void *userData) +// // { +// // (void)userData; +// // s_cardInserted = isInserted; +// // xSemaphoreGiveFromISR(s_CardDetectSemaphore, NULL); +// // } + +// // static void CardDetectTask(void *pvParameters) +// // { +// // (void)pvParameters; + +// // while (true) +// // { +// // if (!s_cardInserted) +// // { +// // /* power off card */ +// // SD_PowerOffCard(g_sd.host.base, g_sd.usrParam.pwr); +// // } + +// // /* take card detect semaphore */ +// // xSemaphoreTake(s_CardDetectSemaphore, portMAX_DELAY); +// // vTaskDelay(100 / portTICK_PERIOD_MS); +// // if (s_cardInserted) +// // { +// // //Card inserted. +// // /* power on the card */ +// // SD_PowerOnCard(g_sd.host.base, g_sd.usrParam.pwr); +// // /* Init card. */ +// // if (SD_CardInit(&g_sd)) +// // { +// // //SD card init failed. +// // continue; +// // } + +// // FRESULT err = f_mount(&sdCard_FS, "0", 1U); +// // if (err != FR_OK) { +// // vTaskDelay(1000 / portTICK_PERIOD_MS); +// // SD_CardDeinit(&g_sd); +// // continue; +// // } +// // sdCardFileSystemReady = true; + +// // // post event to managed app +// // PostManagedEvent( EVENT_STORAGE, 0, StorageEventType_RemovableDeviceInsertion, +// SD_CARD_DRIVE_INDEX_NUMERIC ); +// // } +// // else +// // { +// // SD_CardDeinit(&g_sd); + +// // //Card removed +// // sdCardFileSystemReady = false; + +// // // post event to managed app +// // PostManagedEvent( EVENT_STORAGE, 0, StorageEventType_RemovableDeviceRemoval, +// SD_CARD_DRIVE_INDEX_NUMERIC ); +// // } +// // } +// // } + +// // void SdCardThread(void * argument) +// // { +// // (void)argument; + +// // s_CardDetectSemaphore = xSemaphoreCreateBinary(); + +// // sdCardFileSystemReady = false; + +// // g_sd.host.base = SD_HOST_BASEADDR; +// // g_sd.host.sourceClock_Hz = SD_HOST_CLK_FREQ; +// // g_sd.usrParam.cd = &s_sdCardDetect; + +// // NVIC_SetPriority(SD_HOST_IRQ, 5U); + +// // /* SD host init function */ +// // if (SD_HostInit(&g_sd) != kStatus_Success) +// // { +// // //SD host init fail +// // vTaskDelete(NULL); +// // return; +// // } + +// // xTaskCreate(CardDetectTask, "CardDetectTask", configMINIMAL_STACK_SIZE + 500, NULL, configMAX_PRIORITIES - 2, +// NULL); + +// // vTaskDelete(NULL); +// // } diff --git a/targets/FreeRTOS/NXP/_common/Target_Windows_Storage.c b/targets/FreeRTOS/NXP/_common/Target_Windows_Storage.c deleted file mode 100644 index 8f0f46c390..0000000000 --- a/targets/FreeRTOS/NXP/_common/Target_Windows_Storage.c +++ /dev/null @@ -1,149 +0,0 @@ -// -// Copyright (c) .NET Foundation and Contributors -// See LICENSE file in the project root for full license information. -// - -#include "FreeRTOS.h" -#include "semphr.h" -#include "task.h" - -#include "ff.h" -#include -#include -#include - -#include "fsl_sd.h" - - -// need to declare this here as extern -extern void PostManagedEvent(uint8_t category, uint8_t subCategory, uint16_t data1, uint32_t data2); - -#define SD_CARD_DRIVE_INDEX "0" -#define SD_CARD_DRIVE_INDEX_NUMERIC (0) - - -/////////////////////////////////////////// -// code specific to SD Card - -// FS for SD Card mounted and ready -bool sdCardFileSystemReady; - -static FATFS sdCard_FS; - -/*! -* call back function for SD card detect. -* -* @param isInserted true, indicate the card is insert. -* false, indicate the card is remove. -* @param userData -*/ -static void SDCARD_DetectCallBack(bool isInserted, void *userData); - -/*! Card descriptor. */ -sd_card_t g_sd; - -/*! SDMMC host detect card configuration */ -static const sdmmchost_detect_card_t s_sdCardDetect = { -#ifndef BOARD_SD_DETECT_TYPE - .cdType = kSDMMCHOST_DetectCardByGpioCD, -#else - .cdType = BOARD_SD_DETECT_TYPE, -#endif - .cdTimeOut_ms = (~0U), - .cardInserted = SDCARD_DetectCallBack, - .cardRemoved = SDCARD_DetectCallBack, -}; - -/*! SD card detect flag */ -static bool s_cardInserted = false; -/*! Card semaphore */ -static SemaphoreHandle_t s_CardDetectSemaphore = NULL; - -static void SDCARD_DetectCallBack(bool isInserted, void *userData) -{ - (void)userData; - s_cardInserted = isInserted; - xSemaphoreGiveFromISR(s_CardDetectSemaphore, NULL); -} - -static void CardDetectTask(void *pvParameters) -{ - (void)pvParameters; - - while (true) - { - if (!s_cardInserted) - { - /* power off card */ - SD_PowerOffCard(g_sd.host.base, g_sd.usrParam.pwr); - } - - /* take card detect semaphore */ - xSemaphoreTake(s_CardDetectSemaphore, portMAX_DELAY); - vTaskDelay(100 / portTICK_PERIOD_MS); - if (s_cardInserted) - { - //Card inserted. - /* power on the card */ - SD_PowerOnCard(g_sd.host.base, g_sd.usrParam.pwr); - /* Init card. */ - if (SD_CardInit(&g_sd)) - { - //SD card init failed. - continue; - } - - FRESULT err = f_mount(&sdCard_FS, "0", 1U); - if (err != FR_OK) { - vTaskDelay(1000 / portTICK_PERIOD_MS); - SD_CardDeinit(&g_sd); - continue; - } - sdCardFileSystemReady = true; - - // post event to managed app - PostManagedEvent( EVENT_STORAGE, 0, StorageEventType_RemovableDeviceInsertion, SD_CARD_DRIVE_INDEX_NUMERIC ); - } - else - { - SD_CardDeinit(&g_sd); - - //Card removed - sdCardFileSystemReady = false; - - // post event to managed app - PostManagedEvent( EVENT_STORAGE, 0, StorageEventType_RemovableDeviceRemoval, SD_CARD_DRIVE_INDEX_NUMERIC ); - } - } -} - -void SdCardThread(void * argument) -{ - (void)argument; - - s_CardDetectSemaphore = xSemaphoreCreateBinary(); - - sdCardFileSystemReady = false; - - g_sd.host.base = SD_HOST_BASEADDR; - g_sd.host.sourceClock_Hz = SD_HOST_CLK_FREQ; - g_sd.usrParam.cd = &s_sdCardDetect; - - NVIC_SetPriority(SD_HOST_IRQ, 5U); - - /* SD host init function */ - if (SD_HostInit(&g_sd) != kStatus_Success) - { - //SD host init fail - vTaskDelete(NULL); - return; - } - - xTaskCreate(CardDetectTask, "CardDetectTask", configMINIMAL_STACK_SIZE + 500, NULL, configMAX_PRIORITIES - 2, NULL); - - vTaskDelete(NULL); -} - - -/////////////////////////////////////////// - diff --git a/targets/FreeRTOS/NXP/_include/Target_Windows_Storage.h b/targets/FreeRTOS/NXP/_include/Target_Windows_Storage.h deleted file mode 100644 index 3015ff8340..0000000000 --- a/targets/FreeRTOS/NXP/_include/Target_Windows_Storage.h +++ /dev/null @@ -1,21 +0,0 @@ -// -// Copyright (c) .NET Foundation and Contributors -// See LICENSE file in the project root for full license information. -// - -#ifndef TARGET_WINDOWS_STORAGE_H -#define TARGET_WINDOWS_STORAGE_H - -#ifdef __cplusplus -extern "C" { -#endif - - // declaration of storage working threads - void SdCardThread(void * argument); - -#ifdef __cplusplus -} -#endif - - -#endif // TARGET_WINDOWS_STORAGE_H diff --git a/targets/FreeRTOS/NXP/_nanoCLR/Windows.Storage/win_storage_native_Windows_Storage_Devices_SDCard.cpp b/targets/FreeRTOS/NXP/_nanoCLR/Windows.Storage/win_storage_native_Windows_Storage_Devices_SDCard.cpp deleted file mode 100644 index 23268d9a55..0000000000 --- a/targets/FreeRTOS/NXP/_nanoCLR/Windows.Storage/win_storage_native_Windows_Storage_Devices_SDCard.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// -// Copyright (c) .NET Foundation and Contributors -// See LICENSE file in the project root for full license information. -// - -#include "win_storage_native_target.h" - -HRESULT Library_win_storage_native_Windows_Storage_Devices_SDCard::MountMMCNative___STATIC__VOID__BOOLEAN(CLR_RT_StackFrame& stack) -{ - NANOCLR_HEADER(); - (void)stack; - - NANOCLR_SET_AND_LEAVE(stack.NotImplementedStub()); - - NANOCLR_NOCLEANUP(); -} - -HRESULT Library_win_storage_native_Windows_Storage_Devices_SDCard::MountSpiNative___STATIC__VOID__I4__I4(CLR_RT_StackFrame& stack) -{ - NANOCLR_HEADER(); - (void)stack; - - NANOCLR_SET_AND_LEAVE(stack.NotImplementedStub()); - - NANOCLR_NOCLEANUP(); -} - - -HRESULT Library_win_storage_native_Windows_Storage_Devices_SDCard::UnmountNative___STATIC__VOID(CLR_RT_StackFrame& stack) -{ - NANOCLR_HEADER(); - (void)stack; - - NANOCLR_SET_AND_LEAVE(stack.NotImplementedStub()); - - NANOCLR_NOCLEANUP(); -} diff --git a/targets/FreeRTOS/NXP/_nanoCLR/Windows.Storage/win_storage_native_Windows_Storage_FileIO.cpp b/targets/FreeRTOS/NXP/_nanoCLR/Windows.Storage/win_storage_native_Windows_Storage_FileIO.cpp deleted file mode 100644 index e752c9874f..0000000000 --- a/targets/FreeRTOS/NXP/_nanoCLR/Windows.Storage/win_storage_native_Windows_Storage_FileIO.cpp +++ /dev/null @@ -1,610 +0,0 @@ -// -// Copyright (c) .NET Foundation and Contributors -// See LICENSE file in the project root for full license information. -// - -#include "win_storage_native_target.h" - -// defining these types here to make it shorter and improve code readability -typedef Library_win_storage_native_Windows_Storage_StorageFolder StorageFolder; -typedef Library_win_storage_native_Windows_Storage_StorageFile StorageFile; - -////////////////////////////////////////// - -struct FileIOFileOperation -{ - const char *FileName; - char *Content; - uint32_t ContentLength; -}; - -// this is the FileIO working thread -static volatile FRESULT threadOperationResult; - -// ReadText working thread -static void ReadTextWorkingThread(void *arg) -{ - - FileIOFileOperation *fileIoOperation = reinterpret_cast(arg); - - FIL file; - - // need an extra one for the terminator - uint32_t readLength = fileIoOperation->ContentLength + 1; - - // open file (which is supposed to already exist) - // need to use FA_OPEN_EXISTING because we are reading an existing file content from start - threadOperationResult = f_open(&file, fileIoOperation->FileName, FA_OPEN_EXISTING | FA_READ); - - if (threadOperationResult != FR_OK) - { - // free memory - platform_free(fileIoOperation); - Events_Set(SYSTEM_EVENT_FLAG_STORAGE_IO); - vTaskDelete(NULL); - } - - // read string - if (!(f_gets((TCHAR *)fileIoOperation->Content, readLength, &file))) - { - threadOperationResult = (FRESULT)f_error(&file); - } - - // close file - f_close(&file); - - // free memory - platform_free(fileIoOperation); - - // fire event for FileIO operation complete - Events_Set(SYSTEM_EVENT_FLAG_STORAGE_IO); - - vTaskDelete(NULL); -} - -// WriteText working thread -static void WriteTextWorkingThread(void *arg) -{ - - FileIOFileOperation *fileIoOperation = reinterpret_cast(arg); - - FIL file; - - // open file (which is supposed to already exist) - // need to use FA_OPEN_ALWAYS because we are writting the file content from start - threadOperationResult = f_open(&file, fileIoOperation->FileName, FA_OPEN_ALWAYS | FA_WRITE); - - if (threadOperationResult != FR_OK) - { - // free memory - platform_free(fileIoOperation); - Events_Set(SYSTEM_EVENT_FLAG_STORAGE_IO); - vTaskDelete(NULL); - } - - if (f_puts(fileIoOperation->Content, &file) != (int)fileIoOperation->ContentLength) - { - threadOperationResult = FR_DISK_ERR; - } - - // close file - f_close(&file); - - // free memory - platform_free(fileIoOperation); - - // fire event for FileIO operation complete - Events_Set(SYSTEM_EVENT_FLAG_STORAGE_IO); - - vTaskDelete(NULL); -} - -// WriteBinary working thread -static void WriteBinaryWorkingThread(void *arg) -{ - UINT bytesWritten; - - FileIOFileOperation *fileIoOperation = reinterpret_cast(arg); - - FIL file; - - // open file (which is supposed to already exist) - // need to use FA_OPEN_ALWAYS because we are writting the file content from start - threadOperationResult = f_open(&file, fileIoOperation->FileName, FA_OPEN_ALWAYS | FA_WRITE); - - if (threadOperationResult != FR_OK) - { - // free memory - platform_free(fileIoOperation); - Events_Set(SYSTEM_EVENT_FLAG_STORAGE_IO); - vTaskDelete(NULL); - } - - threadOperationResult = f_write(&file, fileIoOperation->Content, fileIoOperation->ContentLength, &bytesWritten); - if (bytesWritten != fileIoOperation->ContentLength) - { - threadOperationResult = FR_DISK_ERR; - } - // close file - f_close(&file); - - // free memory - platform_free(fileIoOperation); - - // fire event for FileIO operation complete - Events_Set(SYSTEM_EVENT_FLAG_STORAGE_IO); - - vTaskDelete(NULL); -} - -// ReadBinary working thread -static void ReadBinaryWorkingThread(void *arg) -{ - - FileIOFileOperation *fileIoOperation = reinterpret_cast(arg); - - FIL file; - - // need an extra one for the terminator - UINT bytesRead = fileIoOperation->ContentLength + 1; - - // open file (which is supposed to already exist) - // need to use FA_OPEN_EXISTING because we are reading an existing file content from start - threadOperationResult = f_open(&file, fileIoOperation->FileName, FA_OPEN_EXISTING | FA_READ); - - if (threadOperationResult != FR_OK) - { - // free memory - platform_free(fileIoOperation); - Events_Set(SYSTEM_EVENT_FLAG_STORAGE_IO); - vTaskDelete(NULL); - } - - threadOperationResult = f_read(&file, fileIoOperation->Content, fileIoOperation->ContentLength, &bytesRead); - - if (bytesRead != fileIoOperation->ContentLength) - { - threadOperationResult = FR_DISK_ERR; - } - - // close file - f_close(&file); - - platform_free(fileIoOperation); - - // fire event for FileIO operation complete - Events_Set(SYSTEM_EVENT_FLAG_STORAGE_IO); - - vTaskDelete(NULL); -} - -//////////////////////////////////////////////// -// Developer notes: -// Depending on the content size these operations have the potential to be a long running ones as the string or buffer -// is written to the storage. Despite we are not (yet!) async this is better handled by spawning a thread where the -// actual data transfer occurs and not blocking the execution. The underlying RTOS inheritably takes care of making this -// happen "in the background". When the operation is completed a CLR event is fired and the thread execution resumes. -// Being hard to estimate the expected duration of the operation (depends on storage hardware, CPU clock, transfer -// speed, etc) the timeout is set to an infinite timeout the catch is that the working thread MUST ALWAYS return at some -// point -//////////////////////////////////////////////// - -HRESULT Library_win_storage_native_Windows_Storage_FileIO:: - WriteBytes___STATIC__VOID__WindowsStorageIStorageFile__SZARRAY_U1(CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - CLR_RT_HeapBlock_Array *bufferArray; - - CLR_RT_HeapBlock hbTimeout; - CLR_INT64 *timeout; - bool eventResult = true; - - const TCHAR *filePath; - - char *buffer; - uint32_t bufferLength; - - // get a pointer to the managed object instance and check that it's not NULL - CLR_RT_HeapBlock *pThis = stack.This(); - FAULT_ON_NULL(pThis); - - // get a pointer to the buffer - bufferArray = stack.Arg1().DereferenceArray(); - - buffer = (char *)bufferArray->GetFirstElement(); - - bufferLength = bufferArray->m_numOfElements; - - // get a pointer to the file path - filePath = (TCHAR *)pThis[StorageFile::FIELD___path].DereferenceString()->StringText(); - - // !! need to cast to CLR_INT64 otherwise it wont setup a proper timeout infinite - hbTimeout.SetInteger((CLR_INT64)-1); - - NANOCLR_CHECK_HRESULT(stack.SetupTimeoutFromTicks(hbTimeout, timeout)); - - if (stack.m_customState == 1) - { - // protect the content buffer from GC so the working thread can access those - CLR_RT_ProtectFromGC gcContent(*bufferArray); - - // setup FileIO operation - FileIOFileOperation *fileIoOperation = - reinterpret_cast(platform_malloc(sizeof(FileIOFileOperation))); - - // fileIoOperation->File = file; - fileIoOperation->FileName = filePath; - fileIoOperation->Content = buffer; - fileIoOperation->ContentLength = bufferLength; - - // spawn working thread to perform the write transaction - BaseType_t ret; - ret = xTaskCreate( - WriteBinaryWorkingThread, - "WriteBin", - configMINIMAL_STACK_SIZE + 600, - fileIoOperation, - configMAX_PRIORITIES - 2, - NULL); - - if (ret != pdPASS) - { - NANOCLR_SET_AND_LEAVE(CLR_E_PROCESS_EXCEPTION); - } - - // bump custom state - stack.m_customState = 2; - } - - while (eventResult) - { - // non-blocking wait allowing other threads to run while we wait for the write operation to complete - NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.WaitEvents(stack.m_owningThread, *timeout, Event_StorageIo, eventResult)); - - if (eventResult) - { - // event occurred - - if (threadOperationResult == FR_DISK_ERR) - { - NANOCLR_SET_AND_LEAVE(CLR_E_FILE_IO); - } - else if (threadOperationResult == FR_NO_FILE) - { - NANOCLR_SET_AND_LEAVE(CLR_E_FILE_NOT_FOUND); - } - else if (threadOperationResult == FR_INVALID_DRIVE) - { - // failed to change drive - NANOCLR_SET_AND_LEAVE(CLR_E_VOLUME_NOT_FOUND); - } - - // done here - break; - } - else - { - NANOCLR_SET_AND_LEAVE(CLR_E_TIMEOUT); - } - } - // pop timeout heap block from stack - stack.PopValue(); - - NANOCLR_NOCLEANUP(); -} - -HRESULT Library_win_storage_native_Windows_Storage_FileIO::WriteText___STATIC__VOID__WindowsStorageIStorageFile__STRING( - CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - CLR_RT_HeapBlock_String *content; - - CLR_RT_HeapBlock hbTimeout; - CLR_INT64 *timeout; - bool eventResult = true; - - const TCHAR *filePath; - - // get a pointer to the managed object instance and check that it's not NULL - CLR_RT_HeapBlock *pThis = stack.This(); - FAULT_ON_NULL(pThis); - - // get a pointer to the content - content = stack.Arg1().DereferenceString(); - - // get a pointer to the file path - filePath = (TCHAR *)pThis[StorageFile::FIELD___path].DereferenceString()->StringText(); - - // !! need to cast to CLR_INT64 otherwise it wont setup a proper timeout infinite - hbTimeout.SetInteger((CLR_INT64)-1); - - NANOCLR_CHECK_HRESULT(stack.SetupTimeoutFromTicks(hbTimeout, timeout)); - - if (stack.m_customState == 1) - { - // protect the StorageFile and the content buffer from GC so the working thread can access those - CLR_RT_ProtectFromGC gcStorageFile(*pThis); - CLR_RT_ProtectFromGC gcContent(*content); - - // setup FileIO operation - FileIOFileOperation *fileIoOperation = - reinterpret_cast(platform_malloc(sizeof(FileIOFileOperation))); - - fileIoOperation->FileName = filePath; - fileIoOperation->Content = (char *)content->StringText(); - fileIoOperation->ContentLength = hal_strlen_s(fileIoOperation->Content); - - // spawn working thread to perform the write transaction - BaseType_t ret; - ret = xTaskCreate( - WriteTextWorkingThread, - "WriteText", - configMINIMAL_STACK_SIZE + 400, - fileIoOperation, - configMAX_PRIORITIES - 2, - NULL); - - if (ret != pdPASS) - { - NANOCLR_SET_AND_LEAVE(CLR_E_PROCESS_EXCEPTION); - } - - // bump custom state - stack.m_customState = 2; - } - - while (eventResult) - { - // non-blocking wait allowing other threads to run while we wait for the write operation to complete - NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.WaitEvents(stack.m_owningThread, *timeout, Event_StorageIo, eventResult)); - - if (eventResult) - { - // event occurred - if (threadOperationResult == FR_DISK_ERR) - { - NANOCLR_SET_AND_LEAVE(CLR_E_FILE_IO); - } - else if (threadOperationResult == FR_NO_FILE) - { - NANOCLR_SET_AND_LEAVE(CLR_E_FILE_NOT_FOUND); - } - else if (threadOperationResult == FR_INVALID_DRIVE) - { - // failed to change drive - NANOCLR_SET_AND_LEAVE(CLR_E_VOLUME_NOT_FOUND); - } - - // done here - break; - } - else - { - NANOCLR_SET_AND_LEAVE(CLR_E_TIMEOUT); - } - } - // pop timeout heap block from stack - stack.PopValue(); - - NANOCLR_NOCLEANUP(); -} - -HRESULT Library_win_storage_native_Windows_Storage_FileIO:: - ReadBufferNative___STATIC__VOID__WindowsStorageIStorageFile__BYREF_SZARRAY_U1(CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - CLR_RT_HeapBlock hbTimeout; - CLR_INT64 *timeout; - bool eventResult = true; - - const TCHAR *filePath; - - // get a pointer to the managed object instance and check that it's not NULL - CLR_RT_HeapBlock *pThis = stack.This(); - FAULT_ON_NULL(pThis); - - // !! need to cast to CLR_INT64 otherwise it wont setup a proper timeout infinite - hbTimeout.SetInteger((CLR_INT64)-1); - - NANOCLR_CHECK_HRESULT(stack.SetupTimeoutFromTicks(hbTimeout, timeout)); - - // get a pointer to the file path - filePath = (TCHAR *)pThis[StorageFile::FIELD___path].DereferenceString()->StringText(); - - if (stack.m_customState == 1) - { - // get file details - static FILINFO fileInfo; - f_stat(filePath, &fileInfo); - - CLR_RT_HeapBlock buffer; - buffer.SetObjectReference(NULL); - CLR_RT_ProtectFromGC gc2(buffer); - - // create a new byte array with the appropriate size (and type) - NANOCLR_CHECK_HRESULT( - CLR_RT_HeapBlock_Array::CreateInstance(buffer, (CLR_INT32)fileInfo.fsize, g_CLR_RT_WellKnownTypes.m_UInt8)); - - // store this to the argument passed byref - NANOCLR_CHECK_HRESULT(buffer.StoreToReference(stack.Arg1(), 0)); - - // get a pointer to the buffer array to improve readability on the code ahead - CLR_RT_HeapBlock_Array *bufferArray = buffer.DereferenceArray(); - - // setup FileIO operation - FileIOFileOperation *fileIoOperation = - reinterpret_cast(platform_malloc(sizeof(FileIOFileOperation))); - - fileIoOperation->FileName = filePath; - fileIoOperation->Content = (char *)bufferArray->GetFirstElement(); - fileIoOperation->ContentLength = bufferArray->m_numOfElements; - - // spawn working thread to perform the read transaction - BaseType_t ret; - ret = xTaskCreate( - ReadBinaryWorkingThread, - "ReadBin", - configMINIMAL_STACK_SIZE + 600, - fileIoOperation, - configMAX_PRIORITIES - 2, - NULL); - - if (ret != pdPASS) - { - NANOCLR_SET_AND_LEAVE(CLR_E_PROCESS_EXCEPTION); - } - - // bump custom state - stack.m_customState = 2; - } - - while (eventResult) - { - // non-blocking wait allowing other threads to run while we wait for the write operation to complete - NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.WaitEvents(stack.m_owningThread, *timeout, Event_StorageIo, eventResult)); - - if (eventResult) - { - // event occurred - - if (threadOperationResult == FR_DISK_ERR) - { - NANOCLR_SET_AND_LEAVE(CLR_E_FILE_IO); - } - else if (threadOperationResult == FR_NO_FILE) - { - NANOCLR_SET_AND_LEAVE(CLR_E_FILE_NOT_FOUND); - } - else if (threadOperationResult == FR_INVALID_DRIVE) - { - // failed to change drive - NANOCLR_SET_AND_LEAVE(CLR_E_VOLUME_NOT_FOUND); - } - // done here - break; - } - else - { - NANOCLR_SET_AND_LEAVE(CLR_E_TIMEOUT); - } - } - // pop timeout heap block from stack - stack.PopValue(); - - NANOCLR_NOCLEANUP(); -} - -HRESULT Library_win_storage_native_Windows_Storage_FileIO:: - ReadTextNative___STATIC__VOID__WindowsStorageIStorageFile__BYREF_STRING(CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - CLR_RT_HeapBlock hbTimeout; - CLR_INT64 *timeout; - bool eventResult = true; - - const TCHAR *filePath; - - static FILINFO fileInfo; - - // get a pointer to the managed object instance and check that it's not NULL - CLR_RT_HeapBlock *pThis = stack.This(); - FAULT_ON_NULL(pThis); - - // !! need to cast to CLR_INT64 otherwise it wont setup a proper timeout infinite - hbTimeout.SetInteger((CLR_INT64)-1); - - NANOCLR_CHECK_HRESULT(stack.SetupTimeoutFromTicks(hbTimeout, timeout)); - - // get a pointer to the file path - filePath = (TCHAR *)pThis[StorageFile::FIELD___path].DereferenceString()->StringText(); - - if (stack.m_customState == 1) - { - // protect the StorageFile and the content buffer from GC so the working thread can access those - CLR_RT_ProtectFromGC gcStorageFile(*pThis); - - // get file details - f_stat(filePath, &fileInfo); - - // create a new string object with the appropriate size - CLR_RT_HeapBlock hbText; - hbText.SetObjectReference(NULL); - CLR_RT_ProtectFromGC gc(hbText); - - CLR_RT_HeapBlock_String *textString = - CLR_RT_HeapBlock_String::CreateInstance(hbText, (CLR_UINT32)fileInfo.fsize); - FAULT_ON_NULL(textString); - - // store this to the argument passed byref - NANOCLR_CHECK_HRESULT(hbText.StoreToReference(stack.Arg1(), 0)); - - // setup FileIO operation - FileIOFileOperation *fileIoOperation = (FileIOFileOperation *)platform_malloc(sizeof(FileIOFileOperation)); - - fileIoOperation->FileName = filePath; - fileIoOperation->Content = (char *)textString->StringText(); - fileIoOperation->ContentLength = fileInfo.fsize; - - // spawn working thread to perform the read transaction - BaseType_t ret; - ret = xTaskCreate( - ReadTextWorkingThread, - "ReadText", - configMINIMAL_STACK_SIZE + 300, - fileIoOperation, - configMAX_PRIORITIES - 2, - NULL); - - if (ret != pdPASS) - { - NANOCLR_SET_AND_LEAVE(CLR_E_PROCESS_EXCEPTION); - } - - // bump custom state - stack.m_customState = 2; - } - - while (eventResult) - { - // non-blocking wait allowing other threads to run while we wait for the write operation to complete - NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.WaitEvents(stack.m_owningThread, *timeout, Event_StorageIo, eventResult)); - - if (eventResult) - { - // event occurred - - if (threadOperationResult == FR_DISK_ERR) - { - NANOCLR_SET_AND_LEAVE(CLR_E_FILE_IO); - } - else if (threadOperationResult == FR_NO_FILE) - { - NANOCLR_SET_AND_LEAVE(CLR_E_FILE_NOT_FOUND); - } - else if (threadOperationResult == FR_INVALID_DRIVE) - { - // failed to change drive - NANOCLR_SET_AND_LEAVE(CLR_E_VOLUME_NOT_FOUND); - } - - // done here - break; - } - else - { - NANOCLR_SET_AND_LEAVE(CLR_E_TIMEOUT); - } - } - // pop timeout heap block from stack - stack.PopValue(); - - NANOCLR_NOCLEANUP(); -} diff --git a/targets/FreeRTOS/NXP/_nanoCLR/Windows.Storage/win_storage_native_Windows_Storage_StorageFile.cpp b/targets/FreeRTOS/NXP/_nanoCLR/Windows.Storage/win_storage_native_Windows_Storage_StorageFile.cpp deleted file mode 100644 index 4b8cd4723d..0000000000 --- a/targets/FreeRTOS/NXP/_nanoCLR/Windows.Storage/win_storage_native_Windows_Storage_StorageFile.cpp +++ /dev/null @@ -1,151 +0,0 @@ -// -// Copyright (c) .NET Foundation and Contributors -// See LICENSE file in the project root for full license information. -// - -#include "win_storage_native_target.h" - -extern SYSTEMTIME GetDateTime(uint16_t date, uint16_t time); -extern void SaveDateTimeToField(CLR_RT_HeapBlock *hbObj, int fieldIndex, CLR_UINT64 ticks); - -HRESULT Library_win_storage_native_Windows_Storage_StorageFile::DeleteFileNative___VOID(CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - const char *workingPath; - FRESULT operationResult; - - // get a pointer to the managed object instance and check that it's not NULL - CLR_RT_HeapBlock *pThis = stack.This(); - FAULT_ON_NULL(pThis); - - // get a pointer to the path in managed field - workingPath = - pThis[Library_win_storage_native_Windows_Storage_StorageFile::FIELD___path].DereferenceString()->StringText(); - - // Delete folder - operationResult = f_unlink(workingPath); - if (operationResult != FR_OK) - { - // folder doesn't exist - NANOCLR_SET_AND_LEAVE(CLR_E_FILE_NOT_FOUND); - } - - NANOCLR_CLEANUP(); - NANOCLR_CLEANUP_END(); -} - -HRESULT Library_win_storage_native_Windows_Storage_StorageFile::RenameFileNative___VOID__STRING( - CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - const char *workingPath; - const char *desiredPath; - FRESULT operationResult; - - // get a pointer to the managed object instance and check that it's not NULL - CLR_RT_HeapBlock *pThis = stack.This(); - FAULT_ON_NULL(pThis); - - // get a pointer to the path in managed field - workingPath = - pThis[Library_win_storage_native_Windows_Storage_StorageFile::FIELD___path].DereferenceString()->StringText(); - - // get a pointer to the desired folder path - desiredPath = stack.Arg1().DereferenceString()->StringText(); - - // rename folder - operationResult = f_rename(workingPath, desiredPath); - if (operationResult == FR_INVALID_NAME) - { - // invalid path - NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); - } - else if (operationResult != FR_OK) - { - // folder doesn't exist - NANOCLR_SET_AND_LEAVE(CLR_E_DIRECTORY_NOT_FOUND); - } - - NANOCLR_CLEANUP(); - NANOCLR_CLEANUP_END(); -} - -HRESULT Library_win_storage_native_Windows_Storage_StorageFile:: - GetFileFromPathNative___STATIC__WindowsStorageStorageFile__STRING__STRING(CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - CLR_RT_TypeDef_Index storageFileTypeDef; - CLR_RT_HeapBlock *storageFile; - - const char *filePath; - const char *fileName; - - FRESULT fr; - FILINFO fileInfo; - SYSTEMTIME fileInfoTime; - - // get a pointer to the file path - filePath = stack.Arg0().DereferenceString()->StringText(); - - // get a pointer to the file name - fileName = stack.Arg1().DereferenceString()->StringText(); - - fr = f_stat(filePath, &fileInfo); - if (fr == FR_OK) - { - // is this a file? - if (!(fileInfo.fattrib & AM_DIR)) - { - // path represents a file, we are good - - // compose return object - // find type, don't bother checking the result as it exists for sure - g_CLR_RT_TypeSystem.FindTypeDef("StorageFile", "Windows.Storage", storageFileTypeDef); - - // create a - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(stack.PushValue(), storageFileTypeDef)); - - // get a handle to the storage file - storageFile = stack.TopValue().Dereference(); - - // file name - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_String::CreateInstance( - storageFile[Library_win_storage_native_Windows_Storage_StorageFile::FIELD___name], - fileName)); - - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_String::CreateInstance( - storageFile[Library_win_storage_native_Windows_Storage_StorageFile::FIELD___path], - filePath)); - - // get the date time details and fill in the managed field - // compute directory date - fileInfoTime = GetDateTime(fileInfo.fdate, fileInfo.ftime); - - // Save fileInfoTime DateTime to storageFile date created field... - SaveDateTimeToField( - storageFile, - Library_win_storage_native_Windows_Storage_StorageFile::FIELD___dateCreated, - HAL_Time_ConvertFromSystemTime(&fileInfoTime)); - } - else - { - // path exists but it's a folder - NANOCLR_SET_AND_LEAVE(CLR_E_FILE_NOT_FOUND); - } - } - else if (fr == FR_NO_FILE) - { - // file doesn't exist - NANOCLR_SET_AND_LEAVE(CLR_E_FILE_NOT_FOUND); - } - else - { - // IO error - NANOCLR_SET_AND_LEAVE(CLR_E_FILE_IO); - } - - NANOCLR_NOCLEANUP(); -} diff --git a/targets/FreeRTOS/NXP/_nanoCLR/Windows.Storage/win_storage_native_Windows_Storage_StorageFolder.cpp b/targets/FreeRTOS/NXP/_nanoCLR/Windows.Storage/win_storage_native_Windows_Storage_StorageFolder.cpp deleted file mode 100644 index 4a2c7b20c8..0000000000 --- a/targets/FreeRTOS/NXP/_nanoCLR/Windows.Storage/win_storage_native_Windows_Storage_StorageFolder.cpp +++ /dev/null @@ -1,1184 +0,0 @@ -// -// Copyright (c) .NET Foundation and Contributors -// See LICENSE file in the project root for full license information. -// - -#include "win_storage_native_target.h" - -// flags for file system ready -extern bool sdCardFileSystemReady; - -void CombinePath(char *outpath, const char *path1, const char *path2) -{ - strcat(outpath, path1); - - // Add "\" to path if required - if (outpath[hal_strlen_s(outpath) - 1] != '\\') - { - strcat(outpath, "\\"); - } - strcat(outpath, path2); -} - -SYSTEMTIME GetDateTime(uint16_t date, uint16_t time) -{ - SYSTEMTIME fileTime; - - memset(&fileTime, 0, sizeof(SYSTEMTIME)); - - // date (bit15:9) Year origin from 1980 (0..127) - fileTime.wYear = (date >> 9) + 1980; - // date (bit8:5) Month (1..12) - fileTime.wMonth = (date >> 5) & 0x000F; - // date (bit4:0) Day (1..31) - fileTime.wDay = date & 0x001F; - - // time (bit15:11) Hour (0..23) - fileTime.wHour = (time >> 11) & 0x001F; - // time (bit10:5) Minute (0..59) - fileTime.wMinute = (time >> 5) & 0x003F; - // time (bit4:0) Second / 2 (0..29) - fileTime.wSecond = time & 0x001F; - - return fileTime; -} - -// Save a DateTime (ticks) to DateTime field in object -void SaveDateTimeToField(CLR_RT_HeapBlock *hbObj, int fieldIndex, CLR_UINT64 ticks) -{ - CLR_RT_HeapBlock &dateFieldRef = hbObj[fieldIndex]; - CLR_INT64 *pRes = Library_corlib_native_System_DateTime::GetValuePtr(dateFieldRef); - if (pRes) - { - // ...and set it - *pRes = ticks; - } -} - -HRESULT Library_win_storage_native_Windows_Storage_StorageFolder:: - GetRemovableStorageFoldersNative___SZARRAY_WindowsStorageStorageFolder(CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - uint32_t driveCount = 0; - - CLR_RT_HeapBlock *storageFolder; - CLR_RT_TypeDef_Index storageFolderTypeDef; - CLR_RT_HeapBlock &top = stack.PushValueAndClear(); - - // is the SD card file system ready? - if (sdCardFileSystemReady) - { - // add count - driveCount++; - } - - // start composing the reply - // find type definition, don't bother checking the result as it exists for sure - g_CLR_RT_TypeSystem.FindTypeDef("StorageFolder", "Windows.Storage", storageFolderTypeDef); - - // create an array of - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(top, driveCount, storageFolderTypeDef)); - - if (driveCount > 0) - { - // there are driver present and enumerated - - // get a pointer to the first object in the array (which is of type ) - storageFolder = (CLR_RT_HeapBlock *)top.DereferenceArray()->GetFirstElement(); - - // create an instance of - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*storageFolder, storageFolderTypeDef)); - - // loop until we've loaded all the possible drives - // because we are iterating through an enum, need to use its integer values - for (uint16_t driveIterator = 0; driveIterator < driveCount; driveIterator++) - { - char workingDrive[sizeof(DRIVE_PATH_LENGTH)]; - // fill the folder name and path - switch (driveIterator) - { - case 0: - memcpy(workingDrive, INDEX0_DRIVE_PATH, DRIVE_PATH_LENGTH); - break; - - case 1: - memcpy(workingDrive, INDEX1_DRIVE_PATH, DRIVE_PATH_LENGTH); - break; - - default: - // shouldn't reach here - NANOCLR_SET_AND_LEAVE(CLR_E_NOT_SUPPORTED); - break; - } - - // dereference the object in order to reach its fields - CLR_RT_HeapBlock *hbObj = storageFolder->Dereference(); - - // set the managed fields - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_String::CreateInstance( - hbObj[Library_win_storage_native_Windows_Storage_StorageFolder::FIELD___name], - workingDrive)); - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_String::CreateInstance( - hbObj[Library_win_storage_native_Windows_Storage_StorageFolder::FIELD___path], - workingDrive)); - - // malloc stringBuffer to work with FS - char *stringBuffer = (char *)platform_malloc(FF_LFN_BUF + 1); - - // sanity check for successful malloc - if (stringBuffer == NULL) - { - // failed to allocate memory - NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); - } - else - { - // clear buffer - memset(stringBuffer, 0, FF_LFN_BUF + 1); - - // read the drive volume label - // don't bother checking the result, if anything goes wrong we'll end up with an empty string which is - // OK - f_getlabel(workingDrive, stringBuffer, NULL); - - // add the driver letter separated it with an empty space, if the volume label isn't empty - if (*stringBuffer != '\0') - { - strcat(stringBuffer, " "); - } - strcat(stringBuffer, "("); - strcat(stringBuffer, workingDrive); - strcat(stringBuffer, ")"); - - // set the field with the volume label - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_String::CreateInstance( - hbObj[Library_win_storage_native_Windows_Storage_StorageFolder::FIELD___name], - stringBuffer)); - - // free stringBuffer - platform_free(stringBuffer); - } - - // move pointer to the next folder item - storageFolder++; - } - } - - NANOCLR_NOCLEANUP(); -} - -HRESULT Library_win_storage_native_Windows_Storage_StorageFolder:: - GetInternalStorageFoldersNative___SZARRAY_WindowsStorageStorageFolder(CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - { - - CLR_RT_TypeDef_Index storageFolderTypeDef; - CLR_RT_HeapBlock &top = stack.PushValue(); - - // start composing the reply - // find type definition, don't bother checking the result as it exists for sure - g_CLR_RT_TypeSystem.FindTypeDef("StorageFolder", "Windows.Storage", storageFolderTypeDef); - - // create an empty array of - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(top, 0, storageFolderTypeDef)); - } - NANOCLR_NOCLEANUP(); -} - -HRESULT Library_win_storage_native_Windows_Storage_StorageFolder:: - GetStorageFoldersNative___SZARRAY_WindowsStorageStorageFolder(CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - CLR_RT_TypeDef_Index storageFolderTypeDef; - CLR_RT_HeapBlock *storageFolder; - CLR_RT_HeapBlock *hbObj; - SYSTEMTIME fileInfoTime; - - const char *workingPath; - - DIR currentDirectory; - FRESULT operationResult; - static FILINFO fileInfo; - uint16_t directoryCount = 0; - char *stringBuffer = NULL; - char *workingBuffer = NULL; - - CLR_RT_HeapBlock &top = stack.PushValue(); - - // get a pointer to the managed object instance and check that it's not NULL - CLR_RT_HeapBlock *pThis = stack.This(); - FAULT_ON_NULL(pThis); - - // get a pointer to the path in managed field - workingPath = - pThis[Library_win_storage_native_Windows_Storage_StorageFolder::FIELD___path].DereferenceString()->StringText(); - - // open directory - operationResult = f_opendir(¤tDirectory, workingPath); - - if (operationResult != FR_OK) - { - if (operationResult == FR_INVALID_DRIVE) - { - // failed to change drive - NANOCLR_SET_AND_LEAVE(CLR_E_VOLUME_NOT_FOUND); - } - - // error or directory empty - // find type, don't bother checking the result as it exists for sure - g_CLR_RT_TypeSystem.FindTypeDef("StorageFolder", "Windows.Storage", storageFolderTypeDef); - - // create an array of - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(top, directoryCount, storageFolderTypeDef)); - } - else - { - // need to perform this in two steps - // 1st: count the directory objects - // 2nd: create the array items with each directory object - - // perform 1st pass - for (;;) - { - // read next directory item - operationResult = f_readdir(¤tDirectory, &fileInfo); - - // break on error or at end of dir - if (operationResult != FR_OK || fileInfo.fname[0] == 0) - { - break; - } - - // check if this is a directory - // but skip if: - // - has system attribute set - // - has hidden attribute set - if ((fileInfo.fattrib & AM_DIR) && !(fileInfo.fattrib & AM_SYS) && !(fileInfo.fattrib & AM_HID)) - { - directoryCount++; - } - } - - // find type, don't bother checking the result as it exists for sure - g_CLR_RT_TypeSystem.FindTypeDef("StorageFolder", "Windows.Storage", storageFolderTypeDef); - - // create an array of - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(top, directoryCount, storageFolderTypeDef)); - - // get a pointer to the first object in the array (which is of type ) - storageFolder = (CLR_RT_HeapBlock *)top.DereferenceArray()->GetFirstElement(); - - if (directoryCount > 0) - { - // allocate memory for buffers - stringBuffer = (char *)platform_malloc(FF_LFN_BUF + 1); - workingBuffer = (char *)platform_malloc(FF_LFN_BUF + 1); - - // sanity check for successful malloc - if (stringBuffer == NULL || workingBuffer == NULL) - { - // failed to allocate memory - NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); - } - - // perform 2nd pass - // need to rewind the directory read index first - f_readdir(¤tDirectory, NULL); - - for (;;) - { - // read next directory item - operationResult = f_readdir(¤tDirectory, &fileInfo); - - // break on error or at end of dir - if (operationResult != FR_OK || fileInfo.fname[0] == 0) - { - break; - } - - // check if this is a directory - // but skip if: - // - has system attribute set - // - has hidden attribute set - if ((fileInfo.fattrib & AM_DIR) && !(fileInfo.fattrib & AM_SYS) && !(fileInfo.fattrib & AM_HID)) - { - // create an instance of - NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*storageFolder, storageFolderTypeDef)); - - // dereference the object in order to reach its fields - hbObj = storageFolder->Dereference(); - - // directory name - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_String::CreateInstance( - hbObj[Library_win_storage_native_Windows_Storage_StorageFolder::FIELD___name], - fileInfo.fname)); - - // clear working buffer - memset(workingBuffer, 0, FF_LFN_BUF + 1); - - // compose directory path - CombinePath(workingBuffer, workingPath, fileInfo.fname); - - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_String::CreateInstance( - hbObj[Library_win_storage_native_Windows_Storage_StorageFolder::FIELD___path], - workingBuffer)); - - // compute directory date - fileInfoTime = GetDateTime(fileInfo.fdate, fileInfo.ftime); - - // Save created DateTime to StorageFolder date created field... - SaveDateTimeToField( - hbObj, - Library_win_storage_native_Windows_Storage_StorageFolder::FIELD___dateCreated, - HAL_Time_ConvertFromSystemTime(&fileInfoTime)); - - // move the storage folder pointer to the next item in the array - storageFolder++; - } - } - } - } - - NANOCLR_CLEANUP(); - - // close directory - f_closedir(¤tDirectory); - - // free buffers memory, if allocated - if (stringBuffer != NULL) - { - platform_free(stringBuffer); - } - if (workingBuffer != NULL) - { - platform_free(workingBuffer); - } - - NANOCLR_CLEANUP_END(); -} - -HRESULT Library_win_storage_native_Windows_Storage_StorageFolder:: - GetStorageFilesNative___SZARRAY_WindowsStorageStorageFile__U4__U4(CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - CLR_RT_TypeDef_Index storageFileTypeDef; - CLR_RT_HeapBlock *storageFile; - CLR_RT_HeapBlock *hbObj; - SYSTEMTIME fileInfoTime; - - const char *workingPath; - char workingDrive[DRIVE_LETTER_LENGTH]; - - uint32_t startIndex; - uint32_t maxItemsToRetrieve; - - DIR currentDirectory; - FRESULT operationResult; - static FILINFO fileInfo; - uint16_t fileCount = 0; - char *stringBuffer = NULL; - char *workingBuffer = NULL; - - CLR_RT_HeapBlock &top = stack.PushValue(); - - // get a pointer to the managed object instance and check that it's not NULL - CLR_RT_HeapBlock *pThis = stack.This(); - FAULT_ON_NULL(pThis); - - // get start index - startIndex = stack.Arg1().NumericByRef().u4; - - // get max items to retrieve - maxItemsToRetrieve = stack.Arg2().NumericByRef().u4; - - // copy the first 2 letters of the path for the drive - // path is 'D:\folder\file.txt', so we need 'D:' - memcpy( - workingDrive, - pThis[Library_win_storage_native_Windows_Storage_StorageFolder::FIELD___path].DereferenceString()->StringText(), - DRIVE_LETTER_LENGTH); - - // get a pointer to the path in managed field - workingPath = - pThis[Library_win_storage_native_Windows_Storage_StorageFolder::FIELD___path].DereferenceString()->StringText(); - - // open directory - operationResult = f_opendir(¤tDirectory, workingPath); - - if (operationResult != FR_OK) - { - // error or directory empty - // find type, don't bother checking the result as it exists for sure - g_CLR_RT_TypeSystem.FindTypeDef("StorageFile", "Windows.Storage", storageFileTypeDef); - - // create an array of - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(top, fileCount, storageFileTypeDef)); - } - else - { - uint32_t itemIndex = 0; - - // need to perform this in two steps - // 1st: count the file objects - // 2nd: create the array items with each file object - - // perform 1st pass - for (;;) - { - // read next directory item - operationResult = f_readdir(¤tDirectory, &fileInfo); - - // break on error or at end of dir - if (operationResult != FR_OK || fileInfo.fname[0] == 0) - { - break; - } - - // check if this is a file - // but skip if: - // - has system attribute set - // - has hidden attribute set - if ((fileInfo.fattrib & AM_ARC) && !(fileInfo.fattrib & AM_SYS) && !(fileInfo.fattrib & AM_HID)) - { - // check if this file is within the requested parameters - if ((itemIndex >= startIndex) && (fileCount < maxItemsToRetrieve)) - { - fileCount++; - } - - itemIndex++; - } - } - - // find type, don't bother checking the result as it exists for sure - g_CLR_RT_TypeSystem.FindTypeDef("StorageFile", "Windows.Storage", storageFileTypeDef); - - // create an array of - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(top, fileCount, storageFileTypeDef)); - - // get a pointer to the first object in the array (which is of type ) - storageFile = (CLR_RT_HeapBlock *)top.DereferenceArray()->GetFirstElement(); - - if (fileCount > 0) - { - // allocate memory for buffers - stringBuffer = (char *)platform_malloc(FF_LFN_BUF + 1); - workingBuffer = (char *)platform_malloc(FF_LFN_BUF + 1); - - // sanity check for successful malloc - if (stringBuffer == NULL || workingBuffer == NULL) - { - // failed to allocate memory - NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); - } - - // perform 2nd pass - // need to rewind the directory read index first - f_readdir(¤tDirectory, NULL); - - // and reset the file iterator vars too - itemIndex = 0; - fileCount = 0; - - for (;;) - { - // read next directory item - operationResult = f_readdir(¤tDirectory, &fileInfo); - - // break on error or at end of dir - if (operationResult != FR_OK || fileInfo.fname[0] == 0) - { - break; - } - - // check if this is a file - // but skip if: - // - has system attribute set - // - has hidden attribute set - if ((fileInfo.fattrib & AM_ARC) && !(fileInfo.fattrib & AM_SYS) && !(fileInfo.fattrib & AM_HID)) - { - // check if this file is within the requested parameters - if ((itemIndex >= startIndex) && (fileCount < maxItemsToRetrieve)) - { - // create an instance of - NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*storageFile, storageFileTypeDef)); - - // dereference the object in order to reach its fields - hbObj = storageFile->Dereference(); - - // file name - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_String::CreateInstance( - hbObj[Library_win_storage_native_Windows_Storage_StorageFile::FIELD___name], - fileInfo.fname)); - - // clear working buffer - memset(workingBuffer, 0, FF_LFN_BUF + 1); - - // compose file path - CombinePath(workingBuffer, workingPath, fileInfo.fname); - - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_String::CreateInstance( - hbObj[Library_win_storage_native_Windows_Storage_StorageFile::FIELD___path], - workingBuffer)); - - // compute directory date - fileInfoTime = GetDateTime(fileInfo.fdate, fileInfo.ftime); - - // Save created DateTime to StorageFile date created field... - SaveDateTimeToField( - hbObj, - Library_win_storage_native_Windows_Storage_StorageFile::FIELD___dateCreated, - HAL_Time_ConvertFromSystemTime(&fileInfoTime)); - - // move the storage folder pointer to the next item in the array - storageFile++; - - // update iterator var - fileCount++; - } - - // update iterator var - itemIndex++; - } - } - } - else - { - // empty directory - // find type, don't bother checking the result as it exists for sure - g_CLR_RT_TypeSystem.FindTypeDef("StorageFile", "Windows.Storage", storageFileTypeDef); - - // create an array of - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(top, fileCount, storageFileTypeDef)); - } - } - - NANOCLR_CLEANUP(); - - // close directory - f_closedir(¤tDirectory); - - // free buffers memory, if allocated - if (stringBuffer != NULL) - { - platform_free(stringBuffer); - } - if (workingBuffer != NULL) - { - platform_free(workingBuffer); - } - - NANOCLR_CLEANUP_END(); -} - -struct StorageFolderFileOperation -{ - const char *FilePath; - uint8_t mode; - enum CreationCollisionOption options; -}; - -// this is the FileIO working thread -static volatile FRESULT threadOperationResult; - -// CreateFile working thread -static void CreateFileWorkingThread(void *arg) -{ - - StorageFolderFileOperation *fileIoOperation = reinterpret_cast(arg); - - // create file struct - FIL file; - - // open file - FRESULT operationResult = f_open(&file, fileIoOperation->FilePath, fileIoOperation->mode); - - // process operation result according to creation options - if ((operationResult == FR_EXIST) && (fileIoOperation->options == CreationCollisionOption_FailIfExists)) - { - // file already exists - threadOperationResult = FR_EXIST; - f_close(&file); - return; - } - if ((operationResult == FR_NO_FILE) && (fileIoOperation->options == CreationCollisionOption_OpenIfExists)) - { - // file doesn't exist - threadOperationResult = FR_NO_FILE; - f_close(&file); - return; - } - - threadOperationResult = FR_OK; - - // close file - f_close(&file); - - // free memory - platform_free((void *)fileIoOperation->FilePath); - platform_free(fileIoOperation); - - // fire event for FileIO operation complete - Events_Set(SYSTEM_EVENT_FLAG_STORAGE_IO); - - vTaskDelete(NULL); -} - -HRESULT Library_win_storage_native_Windows_Storage_StorageFolder:: - CreateFileNative___WindowsStorageStorageFile__STRING__U4(CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - CLR_RT_HeapBlock hbTimeout; - CLR_INT64 *timeout; - bool eventResult = true; - - CLR_RT_TypeDef_Index storageFileTypeDef; - CLR_RT_HeapBlock *storageFile; - - const char *fileName; - const char *workingPath; - - CreationCollisionOption options; - - char *filePath = NULL; - - // get a pointer to the managed object instance and check that it's not NULL - CLR_RT_HeapBlock *pThis = stack.This(); - FAULT_ON_NULL(pThis); - - // get creation collision options - options = (CreationCollisionOption)stack.Arg2().NumericByRef().u4; - - // get a pointer to the StorageFolder path in managed field - workingPath = - pThis[Library_win_storage_native_Windows_Storage_StorageFolder::FIELD___path].DereferenceString()->StringText(); - - // get a pointer to the desired file name - fileName = stack.Arg1().DereferenceString()->StringText(); - - // !! need to cast to CLR_INT64 otherwise it wont setup a proper timeout infinite - hbTimeout.SetInteger((CLR_INT64)-1); - - NANOCLR_CHECK_HRESULT(stack.SetupTimeoutFromTicks(hbTimeout, timeout)); - - if (stack.m_customState == 1) - { - - // setup file path - filePath = (char *)platform_malloc(FF_LFN_BUF + 1); - - // sanity check for successful malloc - if (filePath == NULL) - { - // failed to allocate memory - NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); - } - - // clear working buffer - memset(filePath, 0, FF_LFN_BUF + 1); - - // compose file path - CombinePath(filePath, workingPath, fileName); - - uint8_t modeFlags = 0; - // compute mode flags from CreationCollisionOption - switch (options) - { - case CreationCollisionOption_ReplaceExisting: - modeFlags = FA_CREATE_ALWAYS; - break; - - case CreationCollisionOption_FailIfExists: - modeFlags = FA_CREATE_NEW; - break; - - case CreationCollisionOption_OpenIfExists: - modeFlags = FA_OPEN_ALWAYS; - break; - - case CreationCollisionOption_GenerateUniqueName: - // this operation is not supported in nanoFramework - NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); - break; - - default: - break; - } - - // setup File operation - StorageFolderFileOperation *fileOperation = - reinterpret_cast(platform_malloc(sizeof(StorageFolderFileOperation))); - - fileOperation->FilePath = filePath; - fileOperation->mode = modeFlags; - - // spawn working thread to perform the write transaction - BaseType_t ret; - ret = xTaskCreate( - CreateFileWorkingThread, - "CreateFile", - configMINIMAL_STACK_SIZE + 600, - fileOperation, - configMAX_PRIORITIES - 2, - NULL); - - if (ret != pdPASS) - { - NANOCLR_SET_AND_LEAVE(CLR_E_PROCESS_EXCEPTION); - } - - // bump custom state - stack.m_customState = 2; - } - - while (eventResult) - { - // non-blocking wait allowing other threads to run while we wait for the write operation to complete - NANOCLR_CHECK_HRESULT( - g_CLR_RT_ExecutionEngine.WaitEvents(stack.m_owningThread, *timeout, Event_StorageIo, eventResult)); - - if (eventResult) - { - // event occurred - - if (threadOperationResult == FR_DISK_ERR) - { - NANOCLR_SET_AND_LEAVE(CLR_E_FILE_IO); - } - else if (threadOperationResult == FR_NO_FILE) - { - NANOCLR_SET_AND_LEAVE(CLR_E_FILE_NOT_FOUND); - } - else if (threadOperationResult == FR_EXIST) - { - NANOCLR_SET_AND_LEAVE(CLR_E_PATH_ALREADY_EXISTS); - } - else if (threadOperationResult == FR_INVALID_DRIVE) - { - // failed to change drive - NANOCLR_SET_AND_LEAVE(CLR_E_VOLUME_NOT_FOUND); - } - - // pop timeout heap block from stack - stack.PopValue(); - - // compose return object - // find type, don't bother checking the result as it exists for sure - g_CLR_RT_TypeSystem.FindTypeDef("StorageFile", "Windows.Storage", storageFileTypeDef); - - // create a - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(stack.PushValue(), storageFileTypeDef)); - - // get a handle to the storage file - storageFile = stack.TopValue().Dereference(); - - // setup file path - filePath = (char *)platform_malloc(FF_LFN_BUF + 1); - - // sanity check for successful malloc - if (filePath == NULL) - { - // failed to allocate memory - NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); - } - - // clear working buffer - memset(filePath, 0, FF_LFN_BUF + 1); - - // compose file path - CombinePath(filePath, workingPath, fileName); - - // file name - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_String::CreateInstance( - storageFile[Library_win_storage_native_Windows_Storage_StorageFile::FIELD___name], - fileName)); - - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_String::CreateInstance( - storageFile[Library_win_storage_native_Windows_Storage_StorageFile::FIELD___path], - filePath)); - - // Save created DateTime to StorageFile date created field... - SaveDateTimeToField( - storageFile, - Library_win_storage_native_Windows_Storage_StorageFile::FIELD___dateCreated, - HAL_Time_CurrentDateTime(false)); - - platform_free(filePath); - - // done here - break; - } - else - { - NANOCLR_SET_AND_LEAVE(CLR_E_TIMEOUT); - } - } - - NANOCLR_NOCLEANUP(); -} - -HRESULT Library_win_storage_native_Windows_Storage_StorageFolder:: - CreateFolderNative___WindowsStorageStorageFolder__STRING__U4(CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - CLR_RT_TypeDef_Index storageFolderTypeDef; - CLR_RT_HeapBlock *storageFolder; - - const char *folderName; - const char *workingPath; - - CreationCollisionOption options; - - static FILINFO fileInfo; - SYSTEMTIME fileInfoTime; - FRESULT operationResult; - char *folderPath = NULL; - { - // get a pointer to the managed object instance and check that it's not NULL - CLR_RT_HeapBlock *pThis = stack.This(); - FAULT_ON_NULL(pThis); - - // get creation collision options - options = (CreationCollisionOption)stack.Arg2().NumericByRef().u4; - - // get a pointer to the path in managed field - workingPath = pThis[Library_win_storage_native_Windows_Storage_StorageFolder::FIELD___path] - .DereferenceString() - ->StringText(); - - // get a pointer to the desired folder name - folderName = stack.Arg1().DereferenceString()->StringText(); - - folderPath = (char *)platform_malloc(FF_LFN_BUF + 1); - - // sanity check for successful malloc - if (folderPath == NULL) - { - // failed to allocate memory - NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); - } - - // clear working buffer - memset(folderPath, 0, FF_LFN_BUF + 1); - - // compose folder path - CombinePath(folderPath, workingPath, folderName); - - // check if folder exists - operationResult = f_stat(folderPath, &fileInfo); - - if (operationResult == FR_OK) - { - if (options == CreationCollisionOption_FailIfExists) - { - // folder already exists - NANOCLR_SET_AND_LEAVE(CLR_E_PATH_ALREADY_EXISTS); - } - else if (options == CreationCollisionOption_ReplaceExisting) - { - // remove folder - operationResult = f_unlink(folderPath); - if (operationResult == FR_INVALID_NAME) - { - // Invalid path - NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); - } - else if (operationResult == FR_DENIED) - { - // folder is propably not empty - // TODO - add recursive deletion of directories and files - NANOCLR_SET_AND_LEAVE(CLR_E_FILE_IO); - } - - // create directory - operationResult = f_mkdir(folderPath); - - if (operationResult == FR_OK) - { - f_stat(folderPath, &fileInfo); - } - else - { - // failed to create the folder - NANOCLR_SET_AND_LEAVE(CLR_E_FILE_IO); - } - } - else if (options == CreationCollisionOption_GenerateUniqueName) - { - // TODO - add generating unique name - NANOCLR_SET_AND_LEAVE(CLR_E_FILE_IO); - } - } - else if (operationResult == FR_NO_FILE) - { - // create directory - operationResult = f_mkdir(folderPath); - - if (operationResult == FR_OK) - { - f_stat(folderPath, &fileInfo); - } - else - { - // failed to create the folder - NANOCLR_SET_AND_LEAVE(CLR_E_FILE_IO); - } - } - - // compose return object - // find type, don't bother checking the result as it exists for sure - g_CLR_RT_TypeSystem.FindTypeDef("StorageFolder", "Windows.Storage", storageFolderTypeDef); - - // create a - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(stack.PushValue(), storageFolderTypeDef)); - - // get a handle to the storage folder - storageFolder = stack.TopValue().Dereference(); - - // folder name - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_String::CreateInstance( - storageFolder[Library_win_storage_native_Windows_Storage_StorageFolder::FIELD___name], - folderName)); - - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_String::CreateInstance( - storageFolder[Library_win_storage_native_Windows_Storage_StorageFolder::FIELD___path], - folderPath)); - - // get the date time details and fill in the managed field - // compute directory date - fileInfoTime = GetDateTime(fileInfo.fdate, fileInfo.ftime); - - // Save created DateTime to StorageFolder date created field... - SaveDateTimeToField( - storageFolder, - Library_win_storage_native_Windows_Storage_StorageFolder::FIELD___dateCreated, - HAL_Time_ConvertFromSystemTime(&fileInfoTime)); - } - NANOCLR_CLEANUP(); - - // free buffer memory, if allocated - if (folderPath != NULL) - { - platform_free(folderPath); - } - - NANOCLR_CLEANUP_END(); -} - -HRESULT Library_win_storage_native_Windows_Storage_StorageFolder::DeleteFolderNative___VOID(CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - const char *workingPath; - // need extra room for the change dir command - char workingDrive[DRIVE_LETTER_LENGTH + 2]; - FRESULT operationResult; - - // get a pointer to the managed object instance and check that it's not NULL - CLR_RT_HeapBlock *pThis = stack.This(); - FAULT_ON_NULL(pThis); - - // get a pointer to the path in managed field - workingPath = - pThis[Library_win_storage_native_Windows_Storage_StorageFolder::FIELD___path].DereferenceString()->StringText(); - - // remove folder - operationResult = f_unlink(workingPath); - if (operationResult == FR_INVALID_NAME) - { - // Invalid path - NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); - } - else if (operationResult == FR_DENIED) - { - // this could be because the folder is not empty or because it's the current folder - - // change directory to the parent directory using f_chdir("2:..") - - // copy the first 2 letters of the path for the drive - // path is 'D:\folder\file.txt', so we need 'D:' - memcpy( - workingDrive, - pThis[Library_win_storage_native_Windows_Storage_StorageFolder::FIELD___path] - .DereferenceString() - ->StringText(), - DRIVE_LETTER_LENGTH); - // make sure there is a terminator - workingDrive[2] = '\0'; - strcat(workingDrive, ".."); - - // change dir to parent - f_chdir(workingDrive); - - // try remove again - operationResult = f_unlink(workingPath); - - if (operationResult == FR_DENIED) - { - // folder not empty - NANOCLR_SET_AND_LEAVE(CLR_E_DIRECTORY_NOT_EMPTY); - } - else if (operationResult != FR_OK) - { - // something else is failing - NANOCLR_SET_AND_LEAVE(CLR_E_FILE_IO); - } - } - else if (operationResult != FR_OK) - { - // folder doesn't exist - NANOCLR_SET_AND_LEAVE(CLR_E_DIRECTORY_NOT_FOUND); - } - - NANOCLR_CLEANUP(); - - NANOCLR_CLEANUP_END(); -} - -HRESULT Library_win_storage_native_Windows_Storage_StorageFolder::RenameFolderNative___VOID__STRING( - CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - const char *workingPath; - const char *desiredPath; - FRESULT operationResult; - - // get a pointer to the managed object instance and check that it's not NULL - CLR_RT_HeapBlock *pThis = stack.This(); - FAULT_ON_NULL(pThis); - - // get a pointer to the path in managed field - workingPath = - pThis[Library_win_storage_native_Windows_Storage_StorageFolder::FIELD___path].DereferenceString()->StringText(); - - // get a pointer to the desired folder name - desiredPath = stack.Arg1().DereferenceString()->StringText(); - - // rename folder - operationResult = f_rename(workingPath, desiredPath); - if (operationResult == FR_INVALID_NAME) - { - // invalid path - NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); - } - else if (operationResult != FR_OK) - { - // folder doesn't exist - NANOCLR_SET_AND_LEAVE(CLR_E_DIRECTORY_NOT_FOUND); - } - - NANOCLR_CLEANUP(); - - NANOCLR_CLEANUP_END(); -} - -HRESULT Library_win_storage_native_Windows_Storage_StorageFolder::GetFolderNative___WindowsStorageStorageFolder__STRING( - CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - CLR_RT_TypeDef_Index storageFolderTypeDef; - CLR_RT_HeapBlock *storageFolder; - - const char *folderName; - const char *workingPath; - - FILINFO fileInfo; - SYSTEMTIME fileInfoTime; - - FRESULT operationResult; - char *folderPath = NULL; - - // get a pointer to the managed object instance and check that it's not NULL - CLR_RT_HeapBlock *pThis = stack.This(); - FAULT_ON_NULL(pThis); - - // get a pointer to the path in managed field - workingPath = - pThis[Library_win_storage_native_Windows_Storage_StorageFolder::FIELD___path].DereferenceString()->StringText(); - - // get a pointer to the desired folder name - folderName = stack.Arg1().DereferenceString()->StringText(); - - folderPath = (char *)platform_malloc(FF_LFN_BUF + 1); - - // sanity check for successful malloc - if (folderPath == NULL) - { - // failed to allocate memory - NANOCLR_SET_AND_LEAVE(CLR_E_OUT_OF_MEMORY); - } - - // clear working buffer - memset(folderPath, 0, FF_LFN_BUF + 1); - - // compose folder path - CombinePath(folderPath, workingPath, folderName); - - // check if directory exists - operationResult = f_stat(folderPath, &fileInfo); - if (operationResult != FR_OK) - { - // folder doesn't exist - NANOCLR_SET_AND_LEAVE(CLR_E_DIRECTORY_NOT_FOUND); - } - else - { - // is this a file? - if (!(fileInfo.fattrib & AM_DIR)) - { - // Path represents a file - NANOCLR_SET_AND_LEAVE(CLR_E_DIRECTORY_NOT_FOUND); - } - else - { - // compose return object - // find type, don't bother checking the result as it exists for sure - g_CLR_RT_TypeSystem.FindTypeDef("StorageFolder", "Windows.Storage", storageFolderTypeDef); - - // create a - NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(stack.PushValue(), storageFolderTypeDef)); - - // get a handle to the storage folder - storageFolder = stack.TopValue().Dereference(); - - // folder name - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_String::CreateInstance( - storageFolder[Library_win_storage_native_Windows_Storage_StorageFolder::FIELD___name], - folderName)); - - NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_String::CreateInstance( - storageFolder[Library_win_storage_native_Windows_Storage_StorageFolder::FIELD___path], - folderPath)); - - // get the date time details and fill in the managed field - // compute directory date - fileInfoTime = GetDateTime(fileInfo.fdate, fileInfo.ftime); - - // Save created DateTime to StorageFolder date created field... - SaveDateTimeToField( - storageFolder, - Library_win_storage_native_Windows_Storage_StorageFolder::FIELD___dateCreated, - HAL_Time_ConvertFromSystemTime(&fileInfoTime)); - } - } - - NANOCLR_CLEANUP(); - - // free buffer memory, if allocated - if (folderPath != NULL) - { - platform_free(folderPath); - } - - NANOCLR_CLEANUP_END(); -} diff --git a/targets/FreeRTOS/NXP/_nanoCLR/Windows.Storage/win_storage_native_Windows_Storage_StorageProvider.cpp b/targets/FreeRTOS/NXP/_nanoCLR/Windows.Storage/win_storage_native_Windows_Storage_StorageProvider.cpp deleted file mode 100644 index fe7ecfe85e..0000000000 --- a/targets/FreeRTOS/NXP/_nanoCLR/Windows.Storage/win_storage_native_Windows_Storage_StorageProvider.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) .NET Foundation and Contributors -// See LICENSE file in the project root for full license information. -// - -#include "win_storage_native_target.h" - -HRESULT Library_win_storage_native_Windows_Storage_StorageProvider::FormatVolume___VOID__STRING( - CLR_RT_StackFrame &stack) -{ - NANOCLR_HEADER(); - - NANOCLR_SET_AND_LEAVE(stack.NotImplementedStub()); - - NANOCLR_NOCLEANUP(); -} diff --git a/targets/FreeRTOS/NXP/_nanoCLR/Windows.Storage/win_storage_native_target.h b/targets/FreeRTOS/NXP/_nanoCLR/Windows.Storage/win_storage_native_target.h deleted file mode 100644 index f07fc31b4f..0000000000 --- a/targets/FreeRTOS/NXP/_nanoCLR/Windows.Storage/win_storage_native_target.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) .NET Foundation and Contributors -// See LICENSE file in the project root for full license information. -// - - -#ifndef WIN_STORAGE_NATIVE_TARGET_H -#define WIN_STORAGE_NATIVE_TARGET_H - -#include -#include -#include "win_storage_native.h" -#include -#include - -#endif // WIN_STORAGE_NATIVE_TARGET_H diff --git a/targets/TI_SimpleLink/_include/Target_Windows_Storage.h b/targets/TI_SimpleLink/_include/Target_Windows_Storage.h deleted file mode 100644 index 7d77ce06e1..0000000000 --- a/targets/TI_SimpleLink/_include/Target_Windows_Storage.h +++ /dev/null @@ -1,9 +0,0 @@ -// -// Copyright (c) .NET Foundation and Contributors -// See LICENSE file in the project root for full license information. -// - -#ifndef TARGET_WINDOWS_STORAGE_H -#define TARGET_WINDOWS_STORAGE_H - -#endif // TARGET_WINDOWS_STORAGE_H diff --git a/targets/netcore/nanoCLR.sln b/targets/netcore/nanoCLR.sln index 3648aaa7ad..55213c660b 100644 --- a/targets/netcore/nanoCLR.sln +++ b/targets/netcore/nanoCLR.sln @@ -21,8 +21,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "System.Math", "..\..\src\CL EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "System.Text", "..\..\src\nanoFramework.System.Text\System.Text.vcxproj", "{70922447-EBF0-4473-B014-776F8C9426E7}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Windows.Storage", "..\..\src\Windows.Storage\Windows.Storage.vcxproj", "{3CAE286F-0EF8-45E4-8111-AFA0AA9282B4}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Features", "Features", "{B5342381-A5C8-429B-99E6-49C86AD55C4E}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Debugger", "..\..\src\CLR\Debugger\Debugger.vcxproj", "{DD397EC4-844B-4B59-A67B-CAD6B46F1F00}" @@ -192,18 +190,6 @@ Global {70922447-EBF0-4473-B014-776F8C9426E7}.Release|x64.Build.0 = Release|x64 {70922447-EBF0-4473-B014-776F8C9426E7}.Release|x86.ActiveCfg = Release|Win32 {70922447-EBF0-4473-B014-776F8C9426E7}.Release|x86.Build.0 = Release|Win32 - {3CAE286F-0EF8-45E4-8111-AFA0AA9282B4}.Debug|Any CPU.ActiveCfg = Debug|x64 - {3CAE286F-0EF8-45E4-8111-AFA0AA9282B4}.Debug|Any CPU.Build.0 = Debug|x64 - {3CAE286F-0EF8-45E4-8111-AFA0AA9282B4}.Debug|x64.ActiveCfg = Debug|x64 - {3CAE286F-0EF8-45E4-8111-AFA0AA9282B4}.Debug|x64.Build.0 = Debug|x64 - {3CAE286F-0EF8-45E4-8111-AFA0AA9282B4}.Debug|x86.ActiveCfg = Debug|Win32 - {3CAE286F-0EF8-45E4-8111-AFA0AA9282B4}.Debug|x86.Build.0 = Debug|Win32 - {3CAE286F-0EF8-45E4-8111-AFA0AA9282B4}.Release|Any CPU.ActiveCfg = Release|x64 - {3CAE286F-0EF8-45E4-8111-AFA0AA9282B4}.Release|Any CPU.Build.0 = Release|x64 - {3CAE286F-0EF8-45E4-8111-AFA0AA9282B4}.Release|x64.ActiveCfg = Release|x64 - {3CAE286F-0EF8-45E4-8111-AFA0AA9282B4}.Release|x64.Build.0 = Release|x64 - {3CAE286F-0EF8-45E4-8111-AFA0AA9282B4}.Release|x86.ActiveCfg = Release|Win32 - {3CAE286F-0EF8-45E4-8111-AFA0AA9282B4}.Release|x86.Build.0 = Release|Win32 {DD397EC4-844B-4B59-A67B-CAD6B46F1F00}.Debug|Any CPU.ActiveCfg = Debug|x64 {DD397EC4-844B-4B59-A67B-CAD6B46F1F00}.Debug|Any CPU.Build.0 = Debug|x64 {DD397EC4-844B-4B59-A67B-CAD6B46F1F00}.Debug|x64.ActiveCfg = Debug|x64 @@ -540,7 +526,6 @@ Global {46556AFC-C248-4082-ABE6-9B07F4E57579} = {E91B7D05-94FA-4E24-8981-411E6A60092E} {D3F92F34-63DB-446F-BD0B-851AD0069805} = {E91B7D05-94FA-4E24-8981-411E6A60092E} {70922447-EBF0-4473-B014-776F8C9426E7} = {E91B7D05-94FA-4E24-8981-411E6A60092E} - {3CAE286F-0EF8-45E4-8111-AFA0AA9282B4} = {E91B7D05-94FA-4E24-8981-411E6A60092E} {DD397EC4-844B-4B59-A67B-CAD6B46F1F00} = {B5342381-A5C8-429B-99E6-49C86AD55C4E} {A5E9AE41-F4FA-40CE-AD82-A7861EBA007B} = {B5342381-A5C8-429B-99E6-49C86AD55C4E} {5D50772E-DAC8-407D-972F-37DEB4450B72} = {B5342381-A5C8-429B-99E6-49C86AD55C4E} diff --git a/targets/netcore/nanoFramework.nanoCLR/nanoFramework.nanoCLR.vcxproj b/targets/netcore/nanoFramework.nanoCLR/nanoFramework.nanoCLR.vcxproj index e7e1bf833a..33d2986e20 100644 --- a/targets/netcore/nanoFramework.nanoCLR/nanoFramework.nanoCLR.vcxproj +++ b/targets/netcore/nanoFramework.nanoCLR/nanoFramework.nanoCLR.vcxproj @@ -320,9 +320,6 @@ {c9264d0a-ac25-46b0-bd08-4a3252427f19} - - {3cae286f-0ef8-45e4-8111-afa0aa9282b4} - {5b70a795-a6f2-44df-8566-5d68d9e892db} diff --git a/targets/win32/nanoCLR.sln b/targets/win32/nanoCLR.sln index 1d37ccbd37..bdd7767419 100644 --- a/targets/win32/nanoCLR.sln +++ b/targets/win32/nanoCLR.sln @@ -64,8 +64,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Runtime.Native", "..\..\src EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nanoFramework.ResourceManager", "..\..\src\nanoFramework.ResourceManager\nanoFramework.ResourceManager.vcxproj", "{4F6DD35B-A0C8-47EE-880A-1224FADE9276}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Windows.Storage", "..\..\src\Windows.Storage\Windows.Storage.vcxproj", "{3CAE286F-0EF8-45E4-8111-AFA0AA9282B4}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Networking.Sntp", "..\..\src\DeviceInterfaces\Networking.Sntp\Networking.Sntp.vcxproj", "{84C62EFC-DBA2-4D47-BB81-322E8902C6D6}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "System.Net", "..\..\src\DeviceInterfaces\System.Net\System.Net.vcxproj", "{87B3B6FB-AE1F-4777-ABBF-3E42E0DEB336}" @@ -386,18 +384,6 @@ Global {4F6DD35B-A0C8-47EE-880A-1224FADE9276}.Release|x64.Build.0 = Release|x64 {4F6DD35B-A0C8-47EE-880A-1224FADE9276}.Release|x86.ActiveCfg = Release|Win32 {4F6DD35B-A0C8-47EE-880A-1224FADE9276}.Release|x86.Build.0 = Release|Win32 - {3CAE286F-0EF8-45E4-8111-AFA0AA9282B4}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {3CAE286F-0EF8-45E4-8111-AFA0AA9282B4}.Debug|Any CPU.Build.0 = Debug|Win32 - {3CAE286F-0EF8-45E4-8111-AFA0AA9282B4}.Debug|x64.ActiveCfg = Debug|x64 - {3CAE286F-0EF8-45E4-8111-AFA0AA9282B4}.Debug|x64.Build.0 = Debug|x64 - {3CAE286F-0EF8-45E4-8111-AFA0AA9282B4}.Debug|x86.ActiveCfg = Debug|Win32 - {3CAE286F-0EF8-45E4-8111-AFA0AA9282B4}.Debug|x86.Build.0 = Debug|Win32 - {3CAE286F-0EF8-45E4-8111-AFA0AA9282B4}.Release|Any CPU.ActiveCfg = Release|Win32 - {3CAE286F-0EF8-45E4-8111-AFA0AA9282B4}.Release|Any CPU.Build.0 = Release|Win32 - {3CAE286F-0EF8-45E4-8111-AFA0AA9282B4}.Release|x64.ActiveCfg = Release|x64 - {3CAE286F-0EF8-45E4-8111-AFA0AA9282B4}.Release|x64.Build.0 = Release|x64 - {3CAE286F-0EF8-45E4-8111-AFA0AA9282B4}.Release|x86.ActiveCfg = Release|Win32 - {3CAE286F-0EF8-45E4-8111-AFA0AA9282B4}.Release|x86.Build.0 = Release|Win32 {84C62EFC-DBA2-4D47-BB81-322E8902C6D6}.Debug|Any CPU.ActiveCfg = Debug|Win32 {84C62EFC-DBA2-4D47-BB81-322E8902C6D6}.Debug|Any CPU.Build.0 = Debug|Win32 {84C62EFC-DBA2-4D47-BB81-322E8902C6D6}.Debug|x64.ActiveCfg = Debug|x64 @@ -482,7 +468,6 @@ Global {70922447-EBF0-4473-B014-776F8C9426E7} = {383CE434-88F9-4BD4-99C3-D7F19558868D} {B829E436-91EA-46B3-949B-3273211C8F56} = {383CE434-88F9-4BD4-99C3-D7F19558868D} {4F6DD35B-A0C8-47EE-880A-1224FADE9276} = {383CE434-88F9-4BD4-99C3-D7F19558868D} - {3CAE286F-0EF8-45E4-8111-AFA0AA9282B4} = {383CE434-88F9-4BD4-99C3-D7F19558868D} {84C62EFC-DBA2-4D47-BB81-322E8902C6D6} = {383CE434-88F9-4BD4-99C3-D7F19558868D} {87B3B6FB-AE1F-4777-ABBF-3E42E0DEB336} = {76169580-0DE3-48D0-9545-8FC438C54094} {46556AFC-C248-4082-ABE6-9B07F4E57579} = {383CE434-88F9-4BD4-99C3-D7F19558868D} diff --git a/targets/win32/nanoCLR/Generated/CLR_RT_InteropAssembliesTable.cpp b/targets/win32/nanoCLR/Generated/CLR_RT_InteropAssembliesTable.cpp index f77f43f2a3..89d588d9aa 100644 --- a/targets/win32/nanoCLR/Generated/CLR_RT_InteropAssembliesTable.cpp +++ b/targets/win32/nanoCLR/Generated/CLR_RT_InteropAssembliesTable.cpp @@ -12,7 +12,6 @@ extern const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_nanoFramework_System extern const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_nanoFramework_Runtime_Native; extern const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_System_Runtime_Serialization; extern const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_nanoFramework_ResourceManager; -extern const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_Windows_Storage; extern const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_nanoFramework_Networking_Sntp; extern const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_System_Net; extern const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_System_IO_Ports; @@ -33,7 +32,6 @@ const CLR_RT_NativeAssemblyData *g_CLR_InteropAssembliesNativeData[] = { &g_CLR_AssemblyNative_System_Runtime_Serialization, &g_CLR_AssemblyNative_nanoFramework_Runtime_Events, &g_CLR_AssemblyNative_nanoFramework_Runtime_Events_EventSink_DriverProcs, - &g_CLR_AssemblyNative_Windows_Storage, &g_CLR_AssemblyNative_nanoFramework_Networking_Sntp, &g_CLR_AssemblyNative_System_Net, &g_CLR_AssemblyNative_System_IO_Ports, diff --git a/targets/win32/nanoCLR/nanoCLR.vcxproj b/targets/win32/nanoCLR/nanoCLR.vcxproj index 721908d80e..de1d8c8bc1 100644 --- a/targets/win32/nanoCLR/nanoCLR.vcxproj +++ b/targets/win32/nanoCLR/nanoCLR.vcxproj @@ -310,9 +310,6 @@ {c9264d0a-ac25-46b0-bd08-4a3252427f19} - - {3cae286f-0ef8-45e4-8111-afa0aa9282b4} -