REGISTER_SYNC("File_writeBytes", FileWriteBytes);
REGISTER_SYNC("File_writeBase64", FileWriteBase64);
REGISTER_SYNC("File_writeString", FileWriteString);
- REGISTER_SYNC("Filesystem_fetchVirtualRoots", FilesystemFetchVirtualRoots);
+ REGISTER_SYNC("Filesystem_fetchAllStorages", FilesystemFetchAllStorages)
REGISTER_SYNC("FileSystemManager_addStorageStateChangeListener", StartListening);
REGISTER_SYNC("FileSystemManager_removeStorageStateChangeListener", StopListening);
REGISTER_SYNC("FileSystemManager_fetchStorages", FileSystemManagerFetchStorages);
FilesystemManager::GetInstance().StatPath(location, onSuccess, onError);
}
-void FilesystemInstance::FilesystemFetchVirtualRoots(const picojson::value& args,
+void FilesystemInstance::FilesystemFetchAllStorages(const picojson::value& args,
picojson::object& out) {
ScopeLogger();
- auto onSuccess = [&](const std::vector<common::VirtualRoot>& result) {
+ auto onSuccess = [&](const common::VirtualStorages& result) {
ScopeLogger("Entered into asynchronous function, onSuccess");
picojson::array roots;
for (const auto& root : result) {
- roots.push_back(root.ToJson());
+ roots.push_back(root->ToJson());
}
ReportSuccess(picojson::value(roots), out);
};
PrepareError(e, out);
};
- FilesystemManager::GetInstance().GetVirtualRoots(onSuccess, onError);
+ FilesystemManager::GetInstance().FetchAllStorages(onSuccess, onError);
}
void FilesystemInstance::FileSystemManagerFetchStorages(const picojson::value& args,
void FileWriteBytes(const picojson::value& args, picojson::object& out);
void FileWriteBase64(const picojson::value& args, picojson::object& out);
void FileWriteString(const picojson::value& args, picojson::object& out);
- void FilesystemFetchVirtualRoots(const picojson::value& args, picojson::object& out);
+ void FilesystemFetchAllStorages(const picojson::value& args, picojson::object& out);
void FileSystemManagerFetchStorages(const picojson::value& args, picojson::object& out);
void FileSystemManagerMakeDirectory(const picojson::value& args, picojson::object& out);
void FileSystemManagerMakeDirectorySync(const picojson::value& args, picojson::object& out);
success_cb(statData);
}
-void FilesystemManager::GetVirtualRoots(
- const std::function<void(const common::VirtualRoots&)>& success_cb,
+void FilesystemManager::FetchAllStorages(
+ const std::function<void(const common::VirtualStorages&)>& success_cb,
const std::function<void(FilesystemError)>& error_cb) {
ScopeLogger();
- success_cb(fs_provider_.GetVirtualPaths());
+ success_cb(fs_provider_.GetAllStorages());
}
void FilesystemManager::CreateFile(const std::string& path,
void FetchStorages(const std::function<void(const common::Storages&)>& success_cb,
const std::function<void(FilesystemError)>& error_cb);
- void GetVirtualRoots(const std::function<void(const common::VirtualRoots&)>& success_cb,
+ void FetchAllStorages(const std::function<void(const common::VirtualStorages&)>& success_cb,
const std::function<void(FilesystemError)>& error_cb);
void CreateFile(const std::string& path,
if (cacheReady) {
return;
}
-
- var result = native_.callSync('Filesystem_fetchVirtualRoots', {});
+ var result = native_.callSync('Filesystem_fetchAllStorages', {});
if (native_.isFailure(result)) {
throw native_.getErrorObject(result);
}
cacheVirtualToReal[virtualRoots[i].name] = {
path: virtualRoots[i].path,
label: virtualRoots[i].name,
- type: FileSystemStorageType.INTERNAL,
- state: FileSystemStorageState.MOUNTED
+ type: virtualRoots[i].type,
+ state: virtualRoots[i].state
};
}
// initalize home directory for correct mapping global paths from tizen 2.4
}
initCache();
-
+ // find virtual root with longest path
+ var foundLength = 0;
+ var foundVirtualRoot;
+ var foundVirtualPath;
for (var virtual_root in cacheVirtualToReal) {
- var real_root_path = cacheVirtualToReal[virtual_root].path;
- if (_virtualPath.indexOf(real_root_path, 0) === 0) {
- return _virtualPath.replace(real_root_path, virtual_root);
+ var real_root_path = cacheVirtualToReal[virtual_root].path
+ if(_virtualPath.indexOf(real_root_path, 0) === 0) {
+ var currentLength = real_root_path.length;
+ if(currentLength > foundLength) {
+ foundLength = currentLength;
+ foundVirtualRoot = virtual_root;
+ foundVirtualPath = real_root_path
+ }
}
}
-
+ if(foundLength != 0) {
+ return _virtualPath.replace(foundVirtualPath, foundVirtualRoot);
+ }
return _virtualPath;
}