void KfmIpc::parse_dirEntry( char *_data, int _len ) { int pos = 0; // Parsing string const char* _name; _name = read_string( _data, pos, _len ); // Parsing string const char* _access; _access = read_string( _data, pos, _len ); // Parsing string const char* _owner; _owner = read_string( _data, pos, _len ); // Parsing string const char* _group; _group = read_string( _data, pos, _len ); // Parsing string const char* _date; _date = read_string( _data, pos, _len ); // Parsing int int _size; _size = read_int( _data, pos, _len ); // Calling function emit dirEntry( _name, _access, _owner, _group, _date, _size ); free( (void*)_name ); free( (void*)_access ); free( (void*)_owner ); free( (void*)_group ); free( (void*)_date ); }
// ----------------------------------------------------------------------------- // Imports all files (including subdirectories) from [directory] into the // archive // ----------------------------------------------------------------------------- bool Archive::importDir(string_view directory) { // Get a list of all files in the directory vector<string> files; for (const auto& item : std::filesystem::recursive_directory_iterator{ directory }) if (item.is_regular_file()) files.push_back(item.path().string()); // Go through files for (const auto& file : files) { StrUtil::Path fn{ StrUtil::replace(file, directory, "") }; // Remove directory from entry name // Split filename into dir+name auto ename = fn.fileName(); auto edir = fn.path(); // Remove beginning \ or / from dir if (StrUtil::startsWith(edir, '\\') || StrUtil::startsWith(edir, '/')) edir.remove_prefix(1); // Add the entry auto dir = createDir(edir); auto entry = addNewEntry(ename, dir->numEntries() + 1, dir); // Load data entry->importFile(file); // Set unmodified entry->setState(ArchiveEntry::State::Unmodified); dir->dirEntry()->setState(ArchiveEntry::State::Unmodified); } return true; }
//------------------------------------------------------------------------------ bool FatFile::printModifyDateTime(print_t* pr) { dir_t dir; if (!dirEntry(&dir)) { DBG_FAIL_MACRO; goto fail; } printFatDate(pr, dir.lastWriteDate); pr->write(' '); printFatTime(pr, dir.lastWriteTime); return true; fail: return false; }
void KDir::slotDirEntry(KDirEntry& entry) // SLOT { KFileInfo *i= new KFileInfo(entry); CHECK_PTR(i); myEntries.append(i); if (filterEntry(i)) { KFileInfo *fi= new KFileInfo(entry); CHECK_PTR(fi); myFilteredEntries.append(fi); myFilteredNames.append(fi->fileName()); emit dirEntry(fi); } }
bool doUndo() override { if (created_) return archive_->removeDir(path_); else { // Create directory auto dir = archive_->createDir(path_); // Restore entries/subdirs if needed if (dir && tree_) dir->merge(tree_.get(), 0, ArchiveEntry::State::Unmodified); if (dir) dir->dirEntry()->setState(ArchiveEntry::State::Unmodified); return !!dir; } }
std::string TileAssembler::getDirEntryNameFromModName(unsigned int pMapId, const std::string& pModPosName) { size_t spos; char buffer[20]; std::string modelFileName = getModNameFromModPosName(pModPosName); //std::string fext = pModPosName.substr(modelFileName.length(),pModPosName.length()); unsigned int fextId = getUniqueNameId(pModPosName); sprintf(buffer, "_%07d",fextId); std::string fext(buffer); spos = modelFileName.find_last_of('/'); std::string fname = modelFileName.substr(spos+1, modelFileName.length()); spos = fname.find_last_of('.'); fname = fname.substr(0,spos); sprintf(buffer, "%03u", pMapId); std::string dirEntry(buffer); dirEntry.append("_"); dirEntry.append(fname); dirEntry.append(fext); dirEntry.append(".vmap"); return(dirEntry); }
BFile* MilkySettingsApplication::_OpenSettingsFile(uint32 openMode) { BPath path; find_directory(B_USER_SETTINGS_DIRECTORY, &path); path.Append("MilkyTracker"); BEntry dirEntry(path.Path()); if (!dirEntry.Exists()) { // MilkyTracker settings dir doesn't exist, create it BDirectory temp; temp.CreateDirectory(path.Path(), NULL); } path.Append("platform_settings"); BFile* file = new BFile(path.Path(), openMode); if (file->InitCheck() != B_OK) { delete file; return NULL; } return file; }
void GeckoMediaPluginServiceParent::ClearNodeIdAndPlugin(DirectoryFilter& aFilter) { nsresult rv; nsCOMPtr<nsIFile> path; // $profileDir/gmp/ rv = GetStorageDir(getter_AddRefs(path)); if (NS_FAILED(rv)) { return; } // $profileDir/gmp/id/ rv = path->AppendNative(NS_LITERAL_CSTRING("id")); if (NS_FAILED(rv)) { return; } // Iterate all sub-folders of $profileDir/gmp/id/ nsCOMPtr<nsISimpleEnumerator> iter; rv = path->GetDirectoryEntries(getter_AddRefs(iter)); if (NS_FAILED(rv)) { return; } bool hasMore = false; nsTArray<nsCString> nodeIDsToClear; while (NS_SUCCEEDED(iter->HasMoreElements(&hasMore)) && hasMore) { nsCOMPtr<nsISupports> supports; rv = iter->GetNext(getter_AddRefs(supports)); if (NS_FAILED(rv)) { continue; } // $profileDir/gmp/id/$hash nsCOMPtr<nsIFile> dirEntry(do_QueryInterface(supports, &rv)); if (NS_FAILED(rv)) { continue; } // Skip non-directory files. bool isDirectory = false; rv = dirEntry->IsDirectory(&isDirectory); if (NS_FAILED(rv) || !isDirectory) { continue; } if (!aFilter(dirEntry)) { continue; } nsAutoCString salt; if (NS_SUCCEEDED(ReadSalt(dirEntry, salt))) { // Keep node IDs to clear data/plugins associated with them later. nodeIDsToClear.AppendElement(salt); // Also remove node IDs from the table. mPersistentStorageAllowed.Remove(salt); } // Now we can remove the directory for the origin pair. if (NS_FAILED(dirEntry->Remove(true))) { NS_WARNING("Failed to delete the directory for the origin pair"); } } // Kill plugins that have node IDs to be cleared. KillPlugins(mPlugins, mMutex, NodeFilter(nodeIDsToClear)); // Clear all matching $profileDir/gmp/storage/$nodeId/ rv = GetStorageDir(getter_AddRefs(path)); if (NS_FAILED(rv)) { return; } rv = path->AppendNative(NS_LITERAL_CSTRING("storage")); if (NS_FAILED(rv)) { return; } for (size_t i = 0; i < nodeIDsToClear.Length(); i++) { nsCOMPtr<nsIFile> dirEntry; rv = path->Clone(getter_AddRefs(dirEntry)); if (NS_FAILED(rv)) { continue; } rv = dirEntry->AppendNative(nodeIDsToClear[i]); if (NS_FAILED(rv)) { continue; } if (NS_FAILED(DeleteDir(dirEntry))) { NS_WARNING("Failed to delete GMP storage directory for the node"); } } }