[KONA]
DF230714-00592
Issue: names returned via API can be invalid.
1. create many files in dir, 1-100.txt files
2. tizen.filesystem.listDirectory("documents", function(files) {f = files; console.log(files) }, function(e) { console.log(e) } )
issued list contains empty names/names with strange characters.
This fixes above problems.
[Verification] With above code, problem doesn't occur.
TCT passrate 100%.
Change-Id: Ief9ec91b0a130d789c8777423f51dfa6b2f6de9d
ReportSuccess(out);
}
-void FilterResult(std::vector<const char*>& names, std::vector<unsigned char>& types, bool is_type,
+void FilterResult(std::vector<std::string>& names,
+ std::vector<unsigned char>& types, bool is_type,
unsigned char type) {
int i = (int)names.size() - 1;
obj["callbackId"] = picojson::value(callback_id);
try {
- std::vector<const char*> names;
+ std::vector<std::string> names;
{
std::vector<unsigned char> types;
- FilesystemUtils::ListDirectory(path, [&](const char* name, unsigned char type) {
- names.push_back(name);
- types.push_back(type);
- });
+ FilesystemUtils::ListDirectory(
+ path, [&](const std::string& name, unsigned char type) {
+ names.push_back(name);
+ types.push_back(type);
+ });
auto it = filter.find("isFile");
if (filter.end() != it) {
void CopyDirectory(const std::string& src, const std::string& dest, bool overwrite) {
ScopeLogger("From: %s, To %s", src.c_str(), dest.c_str());
- ListDirectory(src, [&](const char* name, unsigned char type) {
+ ListDirectory(src, [&](const std::string& name, unsigned char type) {
if (DT_DIR == type) {
std::string dest_dir = dest + '/' + name;
struct stat buf {};
});
}
-void ListDirectory(const std::string& path, std::function<void(const char*, unsigned char)> next) {
+void ListDirectory(
+ const std::string& path,
+ std::function<void(const std::string&, unsigned char)> next) {
ScopeLogger("%s", path.c_str());
DIR* d = ::opendir(path.c_str());
if (nullptr == d) {
if (0 == std::strcmp(entry->d_name, ".") || 0 == std::strcmp(entry->d_name, "..")) {
continue;
}
- next(entry->d_name, entry->d_type);
+ next(std::string(entry->d_name), entry->d_type);
}
}
* @brief Calls 'next' function with name for every entry in given directory
* @throw std::system_error
*/
-void ListDirectory(const std::string& path, std::function<void(const char*, unsigned char)> next);
+void ListDirectory(const std::string& path, std::function<void(const std::string&, unsigned char)> next);
/**
* @brief Removes directory recursively pointed by path.