diff --git a/interfaces/kits/js/src/file_manager_napi.cpp b/interfaces/kits/js/src/file_manager_napi.cpp index 4b3a8f3af91845bd95af9a37b47abd6833373dc1..8d9d0add4876fdfe5333461e5d8a62a786066602 100644 --- a/interfaces/kits/js/src/file_manager_napi.cpp +++ b/interfaces/kits/js/src/file_manager_napi.cpp @@ -73,6 +73,61 @@ UniError DealWithErrno(int err) } } +bool GetDevInfoArg(const NVal &prop, DevInfo &dev) +{ + if (prop.HasProp("name")) { + bool ret = false; + unique_ptr name; + tie(ret, name, ignore) = prop.GetProp("name").ToUTF8String(); + if (!ret) { + return false; + } + dev.SetName(std::string(name.get())); + } + return true; +} + +tuple, unique_ptr, CmdOptions> GetCreateFileArgs(napi_env env, NFuncArg &funcArg) +{ + bool succ = false; + unique_ptr path; + unique_ptr fileName; + CmdOptions option("local", "", 0, 0, false); + tie(succ, path, ignore) = NVal(env, funcArg[CreateFileArgs::CF_PATH]).ToUTF8String(); + if (!succ) { + return {false, nullptr, nullptr, option}; + } + tie(succ, fileName, ignore) = NVal(env, funcArg[CreateFileArgs::CF_FILENAME]).ToUTF8String(); + if (!succ) { + return {false, nullptr, nullptr, option}; + } + + if (funcArg.GetArgc() < CreateFileArgs::CF_OPTION) { + return {false, nullptr, nullptr, option}; + } + + NVal op(env, NVal(env, funcArg[CreateFileArgs::CF_OPTION]).val_); + if (op.TypeIs(napi_function)) { + return {true, move(path), move(fileName), option}; + } + + option.SetHasOpt(true); + if (!op.HasProp("dev")) { + return {true, move(path), move(fileName), option}; + } + + NVal prop(op.GetProp("dev")); + DevInfo dev("local", ""); + if (!GetDevInfoArg(prop, dev)) { + ERR_LOG("CreateFile func get dev para fails"); + option.SetDevInfo(dev); + return {false, nullptr, nullptr, option}; + } + + option.SetDevInfo(dev); + return {true, move(path), move(fileName), option}; +} + napi_value FileManagerNapi::CreateFile(napi_env env, napi_callback_info info) { NFuncArg funcArg(env, info); @@ -81,20 +136,17 @@ napi_value FileManagerNapi::CreateFile(napi_env env, napi_callback_info info) return nullptr; } bool succ = false; - unique_ptr name; unique_ptr path; - tie(succ, name, ignore) = NVal(env, funcArg[CreateFileArgs::CF_FILENAME]).ToUTF8String(); - if (!succ) { - UniError(EINVAL).ThrowErr(env, "Invalid name"); - return nullptr; - } - tie(succ, path, ignore) = NVal(env, funcArg[CreateFileArgs::CF_PATH]).ToUTF8String(); + unique_ptr fileName; + CmdOptions option; + tie(succ, path, fileName, option) = GetCreateFileArgs(env, funcArg); if (!succ) { - UniError(EINVAL).ThrowErr(env, "Invalid path"); + UniError(EINVAL).ThrowErr(env, "CreateFile func get args fails"); return nullptr; } auto arg = make_shared(NVal(env, funcArg.GetThisVar())); - auto cbExec = [arg, name = string(name.get()), path = string(path.get())] (napi_env env) -> UniError { + auto cbExec = [arg, path = string(path.get()), fileName = string(fileName.get()), option = option] + (napi_env env) -> UniError { IFmsClient* client = nullptr; bool succ = false; tie(succ, client) = GetFmsClient(); @@ -102,7 +154,7 @@ napi_value FileManagerNapi::CreateFile(napi_env env, napi_callback_info info) return UniError(ESRCH); } string uri = ""; - int err = client->CreateFile(name, path, arg->uri_); + int err = client->CreateFile(path, fileName, option, arg->uri_); return DealWithErrno(err); }; auto cbComplete = [arg](napi_env env, UniError err) -> NVal { @@ -115,10 +167,12 @@ napi_value FileManagerNapi::CreateFile(napi_env env, napi_callback_info info) string procedureName = "CreateFile"; int argc = funcArg.GetArgc(); NVal thisVar(env, funcArg.GetThisVar()); - if (argc == CREATE_FILE_PARA_MIN) { + if (argc == CREATE_FILE_PARA_MIN || (argc != CREATE_FILE_PARA_MAX && option.GetHasOpt())) { return NAsyncWorkPromise(env, thisVar).Schedule(procedureName, cbExec, cbComplete).val_; } else { - NVal cb(env, funcArg[CreateFileArgs::CF_CALLBACK]); + int cbIdx = (!option.GetHasOpt() ? + CreateFileArgs::CF_CALLBACK_WITHOUT_OP : CreateFileArgs::CF_CALLBACK_WITH_OP); + NVal cb(env, funcArg[cbIdx]); return NAsyncWorkCallback(env, thisVar, cb).Schedule(procedureName, cbExec, cbComplete).val_; } } @@ -138,6 +192,29 @@ void CreateFileArray(napi_env env, shared_ptr arg) } } +bool GetRootArgs(napi_env env, NFuncArg &funcArg, CmdOptions &option) +{ + NVal op(env, NVal(env, funcArg[GetRootArgs::GR_OPTION]).val_); + if (op.TypeIs(napi_function)) { + return true; + } + + option.SetHasOpt(true); + if (!op.HasProp("dev")) { + return true; + } + + NVal prop(op.GetProp("dev")); + DevInfo dev("local", ""); + if (!GetDevInfoArg(prop, dev)) { + option.SetDevInfo(dev); + return false; + } + + option.SetDevInfo(dev); + return true; +} + napi_value FileManagerNapi::GetRoot(napi_env env, napi_callback_info info) { NFuncArg funcArg(env, info); @@ -145,17 +222,26 @@ napi_value FileManagerNapi::GetRoot(napi_env env, napi_callback_info info) UniError(EINVAL).ThrowErr(env, "Number of argments unmatched"); return nullptr; } + + CmdOptions option("local", "", 0, 0, false); + if (funcArg.GetArgc() != 0) { + if (!GetRootArgs(env, funcArg, option)) { + UniError(EINVAL).ThrowErr(env, "GetRoot func get dev para fails"); + return nullptr; + } + } + napi_value fileArr; napi_create_array(env, &fileArr); auto arg = make_shared(NVal(env, fileArr)); - auto cbExec = [arg] (napi_env env) -> UniError { + auto cbExec = [option = option, arg] (napi_env env) -> UniError { IFmsClient* client = nullptr; bool succ = false; tie(succ, client) = GetFmsClient(); if (!succ) { return UniError(ESRCH); } - int err = client->GetRoot("local", arg->fileRes_); + int err = client->GetRoot(option, arg->fileRes_); return DealWithErrno(err); }; auto cbComplete = [arg](napi_env env, UniError err) -> NVal { @@ -169,28 +255,26 @@ napi_value FileManagerNapi::GetRoot(napi_env env, napi_callback_info info) string procedureName = "GetRoot"; int argc = funcArg.GetArgc(); NVal thisVar(env, funcArg.GetThisVar()); - if (argc == GET_ROOT_PARA_MIN) { + if (argc == GET_ROOT_PARA_MIN || (argc != GET_ROOT_PARA_MAX && option.GetHasOpt())) { return NAsyncWorkPromise(env, thisVar).Schedule(procedureName, cbExec, cbComplete).val_; } else { - NVal cb(env, funcArg[GetRootArgs::GR_CALLBACK]); + int cbIdx = (!option.GetHasOpt() ? GetRootArgs::GR_CALLBACK_WITHOUT_OP : GetRootArgs::GR_CALLBACK_WITH_OP); + NVal cb(env, funcArg[cbIdx]); return NAsyncWorkCallback(env, thisVar, cb).Schedule(procedureName, cbExec, cbComplete).val_; } } -bool GetLstFileOption(const NVal &argv, CmdOptions &option) +bool GetListFileOption(const NVal &argv, CmdOptions &option) { bool ret = false; if (argv.HasProp("dev")) { - unique_ptr devName; - NVal dev(argv.GetProp("dev")); - if (dev.HasProp("name")) { - tie(ret, devName, ignore) = dev.GetProp("name").ToUTF8String(); - if (!ret) { - ERR_LOG("ListFileArgs LF_OPTION dev para fails"); - return false; - } - option.SetDevInfo(DevInfo(devName.get(), "")); + NVal prop(argv.GetProp("dev")); + DevInfo dev("local", ""); + if (!GetDevInfoArg(prop, dev)) { + option.SetDevInfo(dev); + return false; } + option.SetDevInfo(dev); } if (argv.HasProp("offset")) { int64_t offset; @@ -219,7 +303,7 @@ tuple, unique_ptr, CmdOptions> GetListFileArg( bool succ = false; unique_ptr path; unique_ptr type; - CmdOptions option; + CmdOptions option("local", "", 0, 0, false); tie(succ, path, ignore) = NVal(env, funcArg[ListFileArgs::LF_PATH]).ToUTF8String(); if (!succ) { ERR_LOG("ListFileArgs LF_PATH para fails"); @@ -236,7 +320,7 @@ tuple, unique_ptr, CmdOptions> GetListFileArg( return {true, move(type), move(path), option}; } option.SetHasOpt(true); - if (!GetLstFileOption(op, option)) { + if (!GetListFileOption(op, option)) { return {false, nullptr, nullptr, option}; } return {true, move(type), move(path), option}; @@ -274,10 +358,10 @@ napi_value FileManagerNapi::ListFile(napi_env env, napi_callback_info info) }; auto cbComplete = [arg](napi_env env, UniError err) -> NVal { - CreateFileArray(env, arg); if (err) { return { env, err.GetNapiErr(env) }; } else { + CreateFileArray(env, arg); return NVal(env, arg->ref_.Deref(env).val_); } }; diff --git a/interfaces/kits/js/src/file_manager_napi_def.h b/interfaces/kits/js/src/file_manager_napi_def.h index 1d008cd986bbe5e1f303b1f4e76bc0cf85e2cf4d..05d753484fda359baf38733764dac37cc666e9fc 100644 --- a/interfaces/kits/js/src/file_manager_napi_def.h +++ b/interfaces/kits/js/src/file_manager_napi_def.h @@ -22,15 +22,17 @@ namespace OHOS { namespace FileManagerService { enum CreateFileArgs { - CF_DEV = 0, + CF_PATH = 0, CF_FILENAME = 1, - CF_PATH = 2, - CF_CALLBACK = 3, + CF_OPTION = 2, + CF_CALLBACK_WITHOUT_OP = 2, + CF_CALLBACK_WITH_OP = 3, }; enum GetRootArgs { - GR_DEV = 0, - GR_CALLBACK = 1, + GR_OPTION = 0, + GR_CALLBACK_WITHOUT_OP = 0, + GR_CALLBACK_WITH_OP = 1, }; enum ListFileArgs { @@ -42,9 +44,9 @@ enum ListFileArgs { }; constexpr int CREATE_FILE_PARA_MAX = 4; -constexpr int CREATE_FILE_PARA_MIN = 3; +constexpr int CREATE_FILE_PARA_MIN = 2; constexpr int GET_ROOT_PARA_MAX = 2; -constexpr int GET_ROOT_PARA_MIN = 1; +constexpr int GET_ROOT_PARA_MIN = 0; constexpr int LIST_FILE_PARA_MAX = 4; constexpr int LIST_FILE_PARA_MIN = 2; } // namespace FileManagerService diff --git a/services/include/file_manager_service_def.h b/services/include/file_manager_service_def.h index 7fb87a7fda3df6fae7d349d422d22a445bd1cc8b..9b49f39dea543e96db1390f019e8b0ce493ce472 100644 --- a/services/include/file_manager_service_def.h +++ b/services/include/file_manager_service_def.h @@ -56,6 +56,7 @@ const std::string ALBUM_TYPE = "album"; const std::string FILE_MIME_TYPE = "file/*"; const std::string EXTERNAL_STORAGE_URI = "dataability:///external_storage"; +const std::string MOUNT_POINT_ROOT = "/mnt/"; constexpr int FILE_MEDIA_TYPE = Media::MediaType::MEDIA_TYPE_FILE; constexpr int RESULTSET_EMPTY = 0; diff --git a/services/include/storage_manager_inf.h b/services/include/storage_manager_inf.h index 6360f084e652e3a214d777baac6815257139a714..aea21f3ef7fecacd1b565167c5955a30d508e51b 100644 --- a/services/include/storage_manager_inf.h +++ b/services/include/storage_manager_inf.h @@ -19,6 +19,7 @@ #include "ipc/storage_manager_proxy.h" #include "ipc/storage_manager.h" #include "istorage_manager.h" +#define VOLUME_ENABLE namespace OHOS { namespace FileManagerService { class StorageManagerInf { diff --git a/services/src/client/file_manager_proxy.cpp b/services/src/client/file_manager_proxy.cpp index f3ee9466037a1084adfc54b3a33eb723db4ac122..b3a120ba2ed6315afd6c1358f14f0d842f9e57d8 100644 --- a/services/src/client/file_manager_proxy.cpp +++ b/services/src/client/file_manager_proxy.cpp @@ -27,15 +27,16 @@ namespace OHOS { namespace FileManagerService { FileManagerProxy::FileManagerProxy(const sptr &impl) : IRemoteProxy(impl) {} -int FileManagerProxy::GetRoot(const std::string &devName, vector> &fileRes) +int FileManagerProxy::GetRoot(const CmdOptions &option, vector> &fileRes) { - if (devName == "external_storage") { + CmdOptions op(option); + if (op.GetDevInfo().GetName() == "external_storage") { MessageParcel data; - data.WriteString(devName); + data.WriteString(op.GetDevInfo().GetName()); MessageParcel reply; - MessageOption option; + MessageOption messageOption; int code = (Equipment::EXTERNAL_STORAGE << EQUIPMENT_SHIFT) | Operation::GET_ROOT; - int err = Remote()->SendRequest(code, data, reply, option); + int err = Remote()->SendRequest(code, data, reply, messageOption); if (err != ERR_NONE) { ERR_LOG("GetRoot inner error send request fail %{public}d", err); return FAIL; @@ -63,14 +64,20 @@ int FileManagerProxy::GetRoot(const std::string &devName, vectorSendRequest(Operation::CREATE_FILE, data, reply, option); + MessageOption messageOption; + int code = Operation::CREATE_FILE; + CmdOptions op(option); + if (op.GetDevInfo().GetName() == "external_storage") { + code = (Equipment::EXTERNAL_STORAGE << EQUIPMENT_SHIFT) | Operation::CREATE_FILE; + } + int err = Remote()->SendRequest(code, data, reply, messageOption); if (err != ERR_NONE) { ERR_LOG("inner error send request fail %{public}d", err); return FAIL; diff --git a/services/src/client/file_manager_proxy.h b/services/src/client/file_manager_proxy.h index 3f733b05a15e5630055108a2f07725388d3c34e8..085d32361989e70bc933156aab91ba787f78c6ec 100644 --- a/services/src/client/file_manager_proxy.h +++ b/services/src/client/file_manager_proxy.h @@ -30,8 +30,9 @@ public: int Mkdir(const std::string &name, const std::string &path) override; int ListFile(const std::string &type, const std::string &path, const CmdOptions &option, std::vector> &fileRes) override; - int CreateFile(const std::string &name, const std::string &path, std::string &uri) override; - int GetRoot(const std::string &devName, std::vector> &fileRes) override; + int CreateFile(const std::string &path, const std::string &fileName, + const CmdOptions &option, std::string &uri) override; + int GetRoot(const CmdOptions &option, std::vector> &fileRes) override; private: static inline BrokerDelegator delegator_; }; diff --git a/services/src/client/ifms_client.h b/services/src/client/ifms_client.h index c03898f6ec03a21cdb12fc6acc61fbe595c74949..386c4febe5c168cdf0a62da52b9acb289fcb65b5 100644 --- a/services/src/client/ifms_client.h +++ b/services/src/client/ifms_client.h @@ -25,8 +25,9 @@ public: virtual int Mkdir(const std::string &name, const std::string &path) = 0; virtual int ListFile(const std::string &type, const std::string &path, const CmdOptions &option, std::vector> &fileRes) = 0; - virtual int GetRoot(const std::string &devName, std::vector> &fileRes) = 0; - virtual int CreateFile(const std::string &name, const std::string &path, std::string &uri) = 0; + virtual int GetRoot(const CmdOptions &option, std::vector> &fileRes) = 0; + virtual int CreateFile(const std::string &path, const std::string &fileName, + const CmdOptions &option, std::string &uri) = 0; }; } // namespace FileManagerService { } // namespace OHOS diff --git a/services/src/fileoper/cmd_options.h b/services/src/fileoper/cmd_options.h index 4eae65c1e696463e561eba0f6bbdd844ce4c7e86..e3619d29a34e0e1f74d96dfd33074ce21b05f685 100644 --- a/services/src/fileoper/cmd_options.h +++ b/services/src/fileoper/cmd_options.h @@ -39,7 +39,7 @@ public: return *this; } - std::string GetName() + std::string GetName() const { return name_; } @@ -49,7 +49,7 @@ public: name_ = name; } - std::string GetPath() + std::string GetPath() const { return path_; } @@ -80,7 +80,7 @@ public: CmdOptions(const CmdOptions &option) = default; CmdOptions& operator=(const CmdOptions& option) = default; - DevInfo GetDevInfo() + DevInfo GetDevInfo() const { return dev_; } @@ -90,7 +90,7 @@ public: dev_ = dev; } - int64_t GetOffset() + int64_t GetOffset() const { return offset_; } @@ -100,7 +100,7 @@ public: offset_ = offset; } - int64_t GetCount() + int64_t GetCount() const { return count_; } @@ -110,7 +110,7 @@ public: count_ = count; } - bool GetHasOpt() + bool GetHasOpt() const { return hasOpt_; } diff --git a/services/src/fileoper/ext_storage/storage_manager_inf.cpp b/services/src/fileoper/ext_storage/storage_manager_inf.cpp index 449eb85a0f52509c8d413752464058b03c18c565..771aff6a5fc7b6a30c8886c346aaef8c7362fd66 100644 --- a/services/src/fileoper/ext_storage/storage_manager_inf.cpp +++ b/services/src/fileoper/ext_storage/storage_manager_inf.cpp @@ -25,8 +25,20 @@ namespace FileManagerService { #ifdef VOLUME_ENABLE static bool GetMountPointFromPath(const string &path, string &mountPoint) { - // need to deal with path - mountPoint = path; + size_t len = MOUNT_POINT_ROOT.size(); + std::string head = path.substr(0, len); + std::string body = path.substr(len); + if (head != MOUNT_POINT_ROOT || body.size() == 0) { + ERR_LOG("invalid mountPoint %{public}s, head check fail", path.c_str()); + return false; + } + + size_t index = body.find("/"); + if (index != std::string::npos) { + mountPoint = MOUNT_POINT_ROOT + body.substr(0, index); + } else { + mountPoint = path; + } return true; } @@ -105,4 +117,3 @@ bool StorageManagerInf::StoragePathValidCheck(const string &path) #endif } // FileManagerService } // OHOS - diff --git a/services/src/fileoper/external_storage_oper.cpp b/services/src/fileoper/external_storage_oper.cpp index da0f6c52c43f2bd0ed3e56e844eadea957ccd0fe..a23e5b92ad1d1ba7d64335f06eb919302539c2db 100644 --- a/services/src/fileoper/external_storage_oper.cpp +++ b/services/src/fileoper/external_storage_oper.cpp @@ -53,7 +53,7 @@ int ExternalStorageOper::OperProcess(uint32_t code, MessageParcel &data, Message string path = data.ReadString(); // name for extension string name = "name"; - errCode = GetRoot(path, name, reply); + errCode = GetRoot(name, path, reply); break; } default: { @@ -64,9 +64,9 @@ int ExternalStorageOper::OperProcess(uint32_t code, MessageParcel &data, Message return errCode; } -int ExternalStorageOper::GetRoot(const std::string &path, const std::string &name, MessageParcel &reply) const +int ExternalStorageOper::GetRoot(const std::string &name, const std::string &path, MessageParcel &reply) const { - return ExternalStorageUtils::DoGetRoot(path, name, reply); + return ExternalStorageUtils::DoGetRoot(name, path, reply); } int ExternalStorageOper::CreateFile(const std::string &uri, const std::string &name, MessageParcel &reply) const diff --git a/services/src/fileoper/external_storage_oper.h b/services/src/fileoper/external_storage_oper.h index 53ee4e2ebca5bd805b38dfec999be2a6ee1f7eff..af5ee57a4d0c23f826e175370fbc8fcd06918b99 100644 --- a/services/src/fileoper/external_storage_oper.h +++ b/services/src/fileoper/external_storage_oper.h @@ -29,7 +29,7 @@ private: int CreateFile(const std::string &uri, const std::string &name, MessageParcel &reply) const; int ListFile(const std::string &type, const std::string &uri, const CmdOptions &option, MessageParcel &reply) const; - int GetRoot(const std::string &path, const std::string &name, MessageParcel &reply) const; + int GetRoot(const std::string &name, const std::string &path, MessageParcel &reply) const; }; } // namespace FileManagerService } // namespace OHOS diff --git a/services/src/fileoper/external_storage_utils.cpp b/services/src/fileoper/external_storage_utils.cpp index 8edf3678392c4fca276462990be1e968a59104c8..4a91e9c58d9d0f9a39de7a1f6d38e42518420572 100644 --- a/services/src/fileoper/external_storage_utils.cpp +++ b/services/src/fileoper/external_storage_utils.cpp @@ -61,18 +61,24 @@ static bool GetRealPath(string &path) static bool GetFileInfo(const std::string &path, const std::string &name, unique_ptr &fileInfo) { - std::string fullPath(""); - fullPath.append(path).append("/").append(name); + std::string fullPath(path); + size_t len = fullPath.size(); + if (fullPath.at(len - 1) != '/') { + fullPath.append("/").append(name); + } else { + fullPath.append(name); + } struct stat st; if (lstat(fullPath.c_str(), &st) != 0) { ERR_LOG("check file info fail."); return false; } - std::string fPath(path.c_str()); + std::string uri(EXTERNAL_STORAGE_URI); std::string fName(name.c_str()); - fileInfo->SetPath(fPath); - std::string type = "file"; + uri.append(fullPath); + fileInfo->SetPath(uri); + std::string type = S_ISDIR(st.st_mode) ? "album" : "file"; fileInfo->SetType(type); fileInfo->SetName(fName); fileInfo->SetSize(st.st_size); @@ -103,14 +109,17 @@ static bool ConvertUriToAbsolutePath(const std::string &uri, std::string &path) int ExternalStorageUtils::DoListFile(const std::string &type, const std::string &uri, MessageParcel &reply) { std::string path; + int fileCount = 0; if (!ConvertUriToAbsolutePath(uri, path)) { ERR_LOG("invalid uri[%{public}s].", uri.c_str()); + reply.WriteInt32(fileCount); return E_NOEXIST; } DIR *dir = opendir(path.c_str()); if (!dir) { ERR_LOG("opendir path[%{public}s] fail.", path.c_str()); + reply.WriteInt32(fileCount); return E_NOEXIST; } std::vector> fileList; @@ -125,7 +134,7 @@ int ExternalStorageUtils::DoListFile(const std::string &type, const std::string fileList.push_back(move(fileInfo)); } closedir(dir); - int fileCount = static_cast(fileList.size()); + fileCount = static_cast(fileList.size()); reply.WriteInt32(fileCount); if (fileCount == 0) { return E_EMPTYFOLDER; @@ -143,8 +152,12 @@ int ExternalStorageUtils::DoCreateFile(const std::string &uri, const std::string ERR_LOG("invalid uri[%{public}s].", uri.c_str()); return E_NOEXIST; } - - path.append("/").append(name); + size_t len = path.size(); + if (path.at(len -1) != '/') { + path.append("/").append(name); + } else { + path.append(name); + } if (access(path.c_str(), F_OK) == 0) { ERR_LOG("target file[%{public}s] exist.", path.c_str()); return E_CREATE_FAIL; @@ -157,11 +170,13 @@ int ExternalStorageUtils::DoCreateFile(const std::string &uri, const std::string } close(fd); - reply.WriteString(uri); + std::string fullUri(EXTERNAL_STORAGE_URI); + fullUri.append(path); + reply.WriteString(fullUri); return SUCCESS; } -int ExternalStorageUtils::DoGetRoot(const std::string &path, const std::string &name, MessageParcel &reply) +int ExternalStorageUtils::DoGetRoot(const std::string &name, const std::string &path, MessageParcel &reply) { vector vecRootPath; #ifdef VOLUME_ENABLE @@ -172,8 +187,8 @@ int ExternalStorageUtils::DoGetRoot(const std::string &path, const std::string & } #endif reply.WriteInt32(vecRootPath.size()); - for (auto path : vecRootPath) { - reply.WriteString(path); + for (auto rootPath : vecRootPath) { + reply.WriteString(rootPath); } return SUCCESS; } diff --git a/services/src/fileoper/external_storage_utils.h b/services/src/fileoper/external_storage_utils.h index c09ba5622b7655703c26aa77528bbc4f0c4975ae..61a139da2f78a11cac8d74788324ef114380334a 100644 --- a/services/src/fileoper/external_storage_utils.h +++ b/services/src/fileoper/external_storage_utils.h @@ -31,7 +31,7 @@ public: static int DoListFile(const std::string &type, const std::string &uri, MessageParcel &reply); static int DoCreateFile(const std::string &uri, const std::string &name, MessageParcel &reply); static bool PopFileInfo(FileInfo &fileInfo, MessageParcel &reply); - static int DoGetRoot(const std::string &path, const std::string &name, MessageParcel &reply); + static int DoGetRoot(const std::string &name, const std::string &path, MessageParcel &reply); }; } // namespace FileManagerService } // namespace OHOS