From 2fdbf0322f73e390550e83d19ff7ee1553e72fbb Mon Sep 17 00:00:00 2001 From: tsdk Date: Fri, 25 Sep 2020 15:40:21 +0100 Subject: [PATCH 01/15] get external drives --- PopEngine.Linux/Makefile | 1 + src/TApiCommon.cpp | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/PopEngine.Linux/Makefile b/PopEngine.Linux/Makefile index 708cfeba..34ef18d6 100644 --- a/PopEngine.Linux/Makefile +++ b/PopEngine.Linux/Makefile @@ -134,6 +134,7 @@ LIB_LINK_LIBS = \ -lm \ -lgbm \ -ldrm \ +-ludev \ LIB_OBJECTS=$(LIB_CPP_FILES:.cpp=.o) $(LIB_C_FILES:.c=.o) APP_OBJECTS=$(APP_SRC_FILES:.cpp=.o) diff --git a/src/TApiCommon.cpp b/src/TApiCommon.cpp index e05a12f9..8fc89373 100644 --- a/src/TApiCommon.cpp +++ b/src/TApiCommon.cpp @@ -60,6 +60,7 @@ namespace ApiPop static void GetPlatform(Bind::TCallback& Params); static void ShellOpen(Bind::TCallback& Params); static void ShowWebPage(Bind::TCallback& Params); + static void GetExternalDrives(Bind::TCallback& Params); // system stuff DEFINE_BIND_FUNCTIONNAME(FileExists); @@ -83,6 +84,7 @@ namespace ApiPop DEFINE_BIND_FUNCTIONNAME(GetPlatform); DEFINE_BIND_FUNCTIONNAME(ShellOpen); DEFINE_BIND_FUNCTIONNAME(ShowWebPage); + DEFINE_BIND_FUNCTIONNAME(GetExternalDrives); // engine stuff DEFINE_BIND_FUNCTIONNAME(CompileAndRun); @@ -667,6 +669,23 @@ void ApiPop::WriteToFile(Bind::TCallback& Params) Soy::ArrayToFile( GetArrayBridge(Contents), Filename, Append ); } +void ApiPop::GetExternalDrives(Bind::TCallback& Params) +{ + // tsdk: possible to allow the user to query a specific subsystem + // char *SUBSYSTEM = "scsi"; + + // os list all external Drives + Array Drives; + auto EnumDrives = [&](const std::string& DrivePath) + { + auto& Drive = Drives.PushBack(DrivePath); + }; + + Platform::EnumExternalDrives( EnumDrives ); + + Params.Return( GetArrayBridge(Drives) ); +} + void ApiPop::GetFilenames(Bind::TCallback& Params) { @@ -747,6 +766,7 @@ void ApiPop::Bind(Bind::TContext& Context) Context.BindGlobalFunction(GetPlatform, Namespace); Context.BindGlobalFunction(ShellOpen, Namespace); Context.BindGlobalFunction(ShowWebPage, Namespace); + Context.BindGlobalFunction(GetExternalDrives, Namespace ); } TImageWrapper::~TImageWrapper() From 79a3abd94b666d07408974633ce40ee4cbb9f0d3 Mon Sep 17 00:00:00 2001 From: tsdk Date: Fri, 25 Sep 2020 15:53:06 +0100 Subject: [PATCH 02/15] updated submodules --- UnitTest | 2 +- src/SoyLib | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/UnitTest b/UnitTest index 1f2aa3ca..f798134d 160000 --- a/UnitTest +++ b/UnitTest @@ -1 +1 @@ -Subproject commit 1f2aa3ca35b66685339067204001d8cea895d5b3 +Subproject commit f798134d9f5ee4764ba5bd9f77128b0f19d0aef5 diff --git a/src/SoyLib b/src/SoyLib index 1d561d60..1e7102af 160000 --- a/src/SoyLib +++ b/src/SoyLib @@ -1 +1 @@ -Subproject commit 1d561d60e37c82c36818567a4de0b1ccd10ffee4 +Subproject commit 1e7102afbd72f2ccd8fad59b14c4e77d879d6ec4 From 00f8aac5be29c44a0f5016a4b948c7712605c1b7 Mon Sep 17 00:00:00 2001 From: tsdk Date: Fri, 25 Sep 2020 16:48:56 +0100 Subject: [PATCH 03/15] linked get Temp Directory Call --- src/TApiCommon.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/TApiCommon.cpp b/src/TApiCommon.cpp index 8fc89373..ef36a26d 100644 --- a/src/TApiCommon.cpp +++ b/src/TApiCommon.cpp @@ -61,6 +61,7 @@ namespace ApiPop static void ShellOpen(Bind::TCallback& Params); static void ShowWebPage(Bind::TCallback& Params); static void GetExternalDrives(Bind::TCallback& Params); + static void GetTempDirectory(Bind::TCallback& Params); // system stuff DEFINE_BIND_FUNCTIONNAME(FileExists); @@ -85,6 +86,7 @@ namespace ApiPop DEFINE_BIND_FUNCTIONNAME(ShellOpen); DEFINE_BIND_FUNCTIONNAME(ShowWebPage); DEFINE_BIND_FUNCTIONNAME(GetExternalDrives); + DEFINE_BIND_FUNCTIONNAME(GetTempDirectory); // engine stuff DEFINE_BIND_FUNCTIONNAME(CompileAndRun); @@ -686,6 +688,10 @@ void ApiPop::GetExternalDrives(Bind::TCallback& Params) Params.Return( GetArrayBridge(Drives) ); } +void ApiPop::GetTempDirectory(Bind::TCallback& Params) +{ + Params.Return( Platform::GetTempDirectory() ); +} void ApiPop::GetFilenames(Bind::TCallback& Params) { @@ -767,6 +773,7 @@ void ApiPop::Bind(Bind::TContext& Context) Context.BindGlobalFunction(ShellOpen, Namespace); Context.BindGlobalFunction(ShowWebPage, Namespace); Context.BindGlobalFunction(GetExternalDrives, Namespace ); + Context.BindGlobalFunction(GetTempDirectory, Namespace ); } TImageWrapper::~TImageWrapper() From e19e09b712d4115e7e21362bf0097570a9cffe1d Mon Sep 17 00:00:00 2001 From: tsdk Date: Fri, 25 Sep 2020 16:49:07 +0100 Subject: [PATCH 04/15] updated submodules --- UnitTest | 2 +- src/SoyLib | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/UnitTest b/UnitTest index f798134d..8fd5d7d3 160000 --- a/UnitTest +++ b/UnitTest @@ -1 +1 @@ -Subproject commit f798134d9f5ee4764ba5bd9f77128b0f19d0aef5 +Subproject commit 8fd5d7d387dce105863b225f7c0d191936843a6c diff --git a/src/SoyLib b/src/SoyLib index 1e7102af..3d118a7d 160000 --- a/src/SoyLib +++ b/src/SoyLib @@ -1 +1 @@ -Subproject commit 1e7102afbd72f2ccd8fad59b14c4e77d879d6ec4 +Subproject commit 3d118a7dd1fee31ffcbfa0844d473b69f8e0756b From a7e1abf2cf62f0141031dc34493a11872f08b649 Mon Sep 17 00:00:00 2001 From: tsdk Date: Mon, 28 Sep 2020 17:23:35 +0100 Subject: [PATCH 05/15] WIP: mount device when writing to it --- .vscode/settings.json | 3 ++- src/TApiCommon.cpp | 24 ++++++++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 55d685dc..7159b11f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -71,6 +71,7 @@ "cfenv": "cpp", "typeinfo": "cpp", "valarray": "cpp", - "variant": "cpp" + "variant": "cpp", + "filesystem": "cpp" } } \ No newline at end of file diff --git a/src/TApiCommon.cpp b/src/TApiCommon.cpp index ef36a26d..7b0b45e8 100644 --- a/src/TApiCommon.cpp +++ b/src/TApiCommon.cpp @@ -137,6 +137,9 @@ namespace ApiPop // TFileMonitor DEFINE_BIND_FUNCTIONNAME(Add); DEFINE_BIND_FUNCTIONNAME(WaitForChange); + + // TDeviceArray + Array> gExternalDrives; } @@ -629,6 +632,8 @@ void ApiPop::WriteToFile(Bind::TCallback& Params) std::string Filename = Params.GetArgumentString(0); + auto* ExternalMount = Platform::GetExternalDrive(Filename); + // gr; work out a better idea for this if ( Soy::StringTrimLeft(Filename,"Documents/",true) || Soy::StringTrimLeft(Filename,"Documents\\",true) ) { @@ -636,6 +641,11 @@ void ApiPop::WriteToFile(Bind::TCallback& Params) //std::Debug << "Platform::GetDocumentsDirectory=" << DocsDir << std::endl; Filename = DocsDir + std::string("/") + Filename; } + // tsdk: for usb devices + else if( Soy::StringTrimLeft(Filename,ExternalMount->mDevicePath,true) ) + { + Filename = ExternalMount->mMountPath + std::string("/") + Filename; + } else { Filename = Params.GetArgumentFilename(0); @@ -677,13 +687,19 @@ void ApiPop::GetExternalDrives(Bind::TCallback& Params) // char *SUBSYSTEM = "scsi"; // os list all external Drives - Array Drives; - auto EnumDrives = [&](const std::string& DrivePath) + Array Drives; + + auto OnDeviceFound = [&](const std::string& SystemPath, const std::string& Capacity) { - auto& Drive = Drives.PushBack(DrivePath); + auto Object = Params.mContext.CreateObjectInstance( Params.mLocalContext ); + // Object.SetString("Device Name", SystemName); + Object.SetString("Mount Path", SystemPath); + Object.SetString("Capacity", Capacity); + + Drives.PushBack(Object); }; - Platform::EnumExternalDrives( EnumDrives ); + Platform::EnumExternalDrives( OnDeviceFound ); Params.Return( GetArrayBridge(Drives) ); } From e6dc3913621c2c9fa1f0e84e08d30142304323fc Mon Sep 17 00:00:00 2001 From: tsdk Date: Tue, 29 Sep 2020 19:32:14 +0100 Subject: [PATCH 06/15] WIP: avle to mount a device but its all hardcoded for now --- src/TApiCommon.cpp | 27 ++++++++++++++++++++------- src/TApiCommon.h | 14 +++++++++++++- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/TApiCommon.cpp b/src/TApiCommon.cpp index 7b0b45e8..430e7d00 100644 --- a/src/TApiCommon.cpp +++ b/src/TApiCommon.cpp @@ -632,7 +632,19 @@ void ApiPop::WriteToFile(Bind::TCallback& Params) std::string Filename = Params.GetArgumentString(0); - auto* ExternalMount = Platform::GetExternalDrive(Filename); + std::shared_ptr ExternalDrive = nullptr; + + auto IsExternalDrive = [&](const std::string& Label, const std::string& DeviceNode, const std::string& Capacity) + { + if ( Soy::StringBeginsWith( Filename, Label, true ) ) + { + std::shared_ptr ptr(new TExternalDrive(Label, DeviceNode)); + gExternalDrives.PushBack( ptr ); + ExternalDrive = ptr; + } + }; + + Platform::EnumExternalDrives( IsExternalDrive ); // gr; work out a better idea for this if ( Soy::StringTrimLeft(Filename,"Documents/",true) || Soy::StringTrimLeft(Filename,"Documents\\",true) ) @@ -642,9 +654,10 @@ void ApiPop::WriteToFile(Bind::TCallback& Params) Filename = DocsDir + std::string("/") + Filename; } // tsdk: for usb devices - else if( Soy::StringTrimLeft(Filename,ExternalMount->mDevicePath,true) ) + else if( ExternalDrive ) { - Filename = ExternalMount->mMountPath + std::string("/") + Filename; + Soy::StringTrimLeft(Filename, ExternalDrive->mLabel,true); + Filename = ExternalDrive->mMountPath + std::string("/") + Filename; } else { @@ -689,11 +702,11 @@ void ApiPop::GetExternalDrives(Bind::TCallback& Params) // os list all external Drives Array Drives; - auto OnDeviceFound = [&](const std::string& SystemPath, const std::string& Capacity) + auto OnDeviceFound = [&](const std::string& Label, const std::string& DeviceNode, const std::string& Capacity) { auto Object = Params.mContext.CreateObjectInstance( Params.mLocalContext ); - // Object.SetString("Device Name", SystemName); - Object.SetString("Mount Path", SystemPath); + Object.SetString("Label", Label); + Object.SetString("DevNode", DeviceNode); Object.SetString("Capacity", Capacity); Drives.PushBack(Object); @@ -701,7 +714,7 @@ void ApiPop::GetExternalDrives(Bind::TCallback& Params) Platform::EnumExternalDrives( OnDeviceFound ); - Params.Return( GetArrayBridge(Drives) ); + Params.Return( GetArrayBridge( Drives ) ); } void ApiPop::GetTempDirectory(Bind::TCallback& Params) diff --git a/src/TApiCommon.h b/src/TApiCommon.h index da13db1f..78d155fb 100644 --- a/src/TApiCommon.h +++ b/src/TApiCommon.h @@ -39,8 +39,9 @@ namespace ApiPop class TFileMonitorWrapper; class TShellExecuteWrapper; - + class TExternalDrive; class TAsyncLoop; + DECLARE_BIND_TYPENAME(AsyncLoop); DECLARE_BIND_TYPENAME(Image); DECLARE_BIND_TYPENAME(FileMonitor); @@ -227,3 +228,14 @@ class ApiPop::TShellExecuteWrapper : public Bind::TObjectWrapper mPendingOutput; // note: no filter between stderr and stdout atm }; +class ApiPop::TExternalDrive +{ +public: + TExternalDrive(const std::string& Label, const std::string& DevNode); + ~TExternalDrive(); + +public: + std::string mLabel; + std::string mDevNode; + std::string mMountPath; +}; \ No newline at end of file From 58b5e2d0755d92ad761b821bbb1229cb3054303f Mon Sep 17 00:00:00 2001 From: thomasSDK Date: Tue, 6 Oct 2020 12:47:48 +0100 Subject: [PATCH 07/15] Updated submodule UnitTest --- UnitTest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnitTest b/UnitTest index 8fd5d7d3..e9249a2f 160000 --- a/UnitTest +++ b/UnitTest @@ -1 +1 @@ -Subproject commit 8fd5d7d387dce105863b225f7c0d191936843a6c +Subproject commit e9249a2f3fc6176a96c4c7dcfe67e3f89111ceac From cc9f4bd8a914ddfd8fb62d17e347244dca5d7c84 Mon Sep 17 00:00:00 2001 From: thomasSDK Date: Tue, 6 Oct 2020 12:50:21 +0100 Subject: [PATCH 08/15] Updated submodule src/SoyLib --- src/SoyLib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SoyLib b/src/SoyLib index 3d118a7d..867fc5c8 160000 --- a/src/SoyLib +++ b/src/SoyLib @@ -1 +1 @@ -Subproject commit 3d118a7dd1fee31ffcbfa0844d473b69f8e0756b +Subproject commit 867fc5c8c91ff4b7e2c2094b33bc90a715499729 From a9a95a2544c2bfee188aa04ffd4dbe6de9efae32 Mon Sep 17 00:00:00 2001 From: tsdk Date: Tue, 6 Oct 2020 14:09:37 +0100 Subject: [PATCH 09/15] create and destroy TExternalDrive --- src/TApiCommon.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/TApiCommon.cpp b/src/TApiCommon.cpp index 430e7d00..8c542805 100644 --- a/src/TApiCommon.cpp +++ b/src/TApiCommon.cpp @@ -2044,3 +2044,17 @@ void ApiPop::TShellExecuteWrapper::OnStdOut(const std::string& Output) } FlushPendingOutput(); } + +ApiPop::TExternalDrive::TExternalDrive(const std::string& Label, const std::string& DevNode) +{ + mLabel = Label; + mDevNode = DevNode; +} + +ApiPop::TExternalDrive::~TExternalDrive() +{ + if(mIsMounted) + Platform::UnMountDrive(mLabel); + + delete this; +} From ad27bc8579a349e0d8de5053d65343b875cbf9f0 Mon Sep 17 00:00:00 2001 From: tsdk Date: Tue, 6 Oct 2020 14:37:36 +0100 Subject: [PATCH 10/15] Create External Drives when listing them --- src/TApiCommon.cpp | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/TApiCommon.cpp b/src/TApiCommon.cpp index 8c542805..af5f2ff3 100644 --- a/src/TApiCommon.cpp +++ b/src/TApiCommon.cpp @@ -696,23 +696,31 @@ void ApiPop::WriteToFile(Bind::TCallback& Params) void ApiPop::GetExternalDrives(Bind::TCallback& Params) { - // tsdk: possible to allow the user to query a specific subsystem - // char *SUBSYSTEM = "scsi"; +// tsdk: TODO Remove devices from global list if they are not found by this function + auto OnDeviceFound = [&](const std::string& Label, const std::string& DevNode, const std::string& Capacity) + { + for( int i = 0; i < gExternalDrives.GetSize(); i++) + { + // tsdk: This is a not very unique better to use a UUID from udev + if(gExternalDrives[i]->mDevNode == DevNode) + return; + } + + auto NewDevice(std::make_shared(Label, DevNode)); + gExternalDrives.PushBack(NewDevice); + }; + + Platform::EnumExternalDrives( OnDeviceFound ); // os list all external Drives Array Drives; - - auto OnDeviceFound = [&](const std::string& Label, const std::string& DeviceNode, const std::string& Capacity) + for( int i = 0; i < gExternalDrives.GetSize(); i++) { auto Object = Params.mContext.CreateObjectInstance( Params.mLocalContext ); - Object.SetString("Label", Label); - Object.SetString("DevNode", DeviceNode); - Object.SetString("Capacity", Capacity); + Object.SetString("Label", gExternalDrives[i]->mLabel); Drives.PushBack(Object); - }; - - Platform::EnumExternalDrives( OnDeviceFound ); + } Params.Return( GetArrayBridge( Drives ) ); } From c8ab1d31622dadbc45c07431853dfe00ea3a894e Mon Sep 17 00:00:00 2001 From: tsdk Date: Tue, 6 Oct 2020 14:57:57 +0100 Subject: [PATCH 11/15] added Mount Method and isMounted bool --- src/TApiCommon.cpp | 7 +++++++ src/TApiCommon.h | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/src/TApiCommon.cpp b/src/TApiCommon.cpp index af5f2ff3..92d63fe6 100644 --- a/src/TApiCommon.cpp +++ b/src/TApiCommon.cpp @@ -2066,3 +2066,10 @@ ApiPop::TExternalDrive::~TExternalDrive() delete this; } + +void ApiPop::TExternalDrive::MountDrive() +{ + Platform::MountDrive(mDevNode, mLabel); + mMountPath = std::string("/media/") + mLabel; + mIsMounted = true; +} \ No newline at end of file diff --git a/src/TApiCommon.h b/src/TApiCommon.h index 78d155fb..3312f48e 100644 --- a/src/TApiCommon.h +++ b/src/TApiCommon.h @@ -237,5 +237,9 @@ class ApiPop::TExternalDrive public: std::string mLabel; std::string mDevNode; + + bool mIsMounted = false; std::string mMountPath; + + void MountDrive(); }; \ No newline at end of file From 76d535a6d7140ebb670abdd37f97373d0d424056 Mon Sep 17 00:00:00 2001 From: tsdk Date: Tue, 6 Oct 2020 14:59:02 +0100 Subject: [PATCH 12/15] Check if path is external Drive --- src/TApiCommon.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/TApiCommon.cpp b/src/TApiCommon.cpp index 92d63fe6..58dc3763 100644 --- a/src/TApiCommon.cpp +++ b/src/TApiCommon.cpp @@ -632,19 +632,24 @@ void ApiPop::WriteToFile(Bind::TCallback& Params) std::string Filename = Params.GetArgumentString(0); - std::shared_ptr ExternalDrive = nullptr; - - auto IsExternalDrive = [&](const std::string& Label, const std::string& DeviceNode, const std::string& Capacity) + auto IsExternalDrive = [&]() { - if ( Soy::StringBeginsWith( Filename, Label, true ) ) + for(int i = 0; i < gExternalDrives.GetSize(); i++) { - std::shared_ptr ptr(new TExternalDrive(Label, DeviceNode)); - gExternalDrives.PushBack( ptr ); - ExternalDrive = ptr; + if(Soy::StringBeginsWith(Filename, gExternalDrives[i]->mLabel, true)) + { + if(gExternalDrives[i]->mIsMounted) + return gExternalDrives[i]; + else + { + gExternalDrives[i]->MountDrive(); + return gExternalDrives[i]; + } + } } }; - Platform::EnumExternalDrives( IsExternalDrive ); + auto ExternalDrive = IsExternalDrive(); // gr; work out a better idea for this if ( Soy::StringTrimLeft(Filename,"Documents/",true) || Soy::StringTrimLeft(Filename,"Documents\\",true) ) From a345283d17b4860dc9f945ade377cc46e456c14a Mon Sep 17 00:00:00 2001 From: tsdk Date: Tue, 6 Oct 2020 16:59:07 +0100 Subject: [PATCH 13/15] Fixed Definition for EnumExternalDevices lamda --- src/TApiCommon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TApiCommon.cpp b/src/TApiCommon.cpp index 58dc3763..f7f900ad 100644 --- a/src/TApiCommon.cpp +++ b/src/TApiCommon.cpp @@ -702,7 +702,7 @@ void ApiPop::WriteToFile(Bind::TCallback& Params) void ApiPop::GetExternalDrives(Bind::TCallback& Params) { // tsdk: TODO Remove devices from global list if they are not found by this function - auto OnDeviceFound = [&](const std::string& Label, const std::string& DevNode, const std::string& Capacity) + auto OnDeviceFound = [&](const std::string& DevNode, const std::string& Label) { for( int i = 0; i < gExternalDrives.GetSize(); i++) { From 26151eaee6b69c56ce6c40bc96eed6831d6a5516 Mon Sep 17 00:00:00 2001 From: tsdk Date: Tue, 6 Oct 2020 17:30:53 +0100 Subject: [PATCH 14/15] remove / --- src/TApiCommon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TApiCommon.cpp b/src/TApiCommon.cpp index f7f900ad..7e5c9089 100644 --- a/src/TApiCommon.cpp +++ b/src/TApiCommon.cpp @@ -662,7 +662,7 @@ void ApiPop::WriteToFile(Bind::TCallback& Params) else if( ExternalDrive ) { Soy::StringTrimLeft(Filename, ExternalDrive->mLabel,true); - Filename = ExternalDrive->mMountPath + std::string("/") + Filename; + Filename = ExternalDrive->mMountPath + Filename; } else { From 350180ac3b81164fcdb2eec98ed56e878bd4d960 Mon Sep 17 00:00:00 2001 From: tsdk Date: Tue, 6 Oct 2020 17:49:26 +0100 Subject: [PATCH 15/15] Unmount Function added --- src/TApiCommon.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/TApiCommon.cpp b/src/TApiCommon.cpp index 7e5c9089..3fcdfdf2 100644 --- a/src/TApiCommon.cpp +++ b/src/TApiCommon.cpp @@ -61,6 +61,7 @@ namespace ApiPop static void ShellOpen(Bind::TCallback& Params); static void ShowWebPage(Bind::TCallback& Params); static void GetExternalDrives(Bind::TCallback& Params); + static void UnMountExternalDrive(Bind::TCallback& Params); static void GetTempDirectory(Bind::TCallback& Params); // system stuff @@ -86,6 +87,7 @@ namespace ApiPop DEFINE_BIND_FUNCTIONNAME(ShellOpen); DEFINE_BIND_FUNCTIONNAME(ShowWebPage); DEFINE_BIND_FUNCTIONNAME(GetExternalDrives); + DEFINE_BIND_FUNCTIONNAME(UnMountExternalDrive); DEFINE_BIND_FUNCTIONNAME(GetTempDirectory); // engine stuff @@ -730,6 +732,20 @@ void ApiPop::GetExternalDrives(Bind::TCallback& Params) Params.Return( GetArrayBridge( Drives ) ); } +void ApiPop::UnMountExternalDrive(Bind::TCallback& Params) +{ + std::string DeviceName = Params.GetArgumentString(0); + + for(int i = 0; i < gExternalDrives.GetSize(); i++) + { + if(gExternalDrives[i]->mLabel == DeviceName) + { + // Do I need to do anything else to here? + gExternalDrives[i].reset(); + } + } +} + void ApiPop::GetTempDirectory(Bind::TCallback& Params) { Params.Return( Platform::GetTempDirectory() ); @@ -815,6 +831,7 @@ void ApiPop::Bind(Bind::TContext& Context) Context.BindGlobalFunction(ShellOpen, Namespace); Context.BindGlobalFunction(ShowWebPage, Namespace); Context.BindGlobalFunction(GetExternalDrives, Namespace ); + Context.BindGlobalFunction(UnMountExternalDrive, Namespace ); Context.BindGlobalFunction(GetTempDirectory, Namespace ); } @@ -2068,8 +2085,6 @@ ApiPop::TExternalDrive::~TExternalDrive() { if(mIsMounted) Platform::UnMountDrive(mLabel); - - delete this; } void ApiPop::TExternalDrive::MountDrive()