void CBFileListTable::ScanDirectory ( const JString& origPath, const JBoolean recurse, const JPtrArray<JString>& allSuffixList, CBSymbolList* symbolList, CBCTree* cTree, CBJavaTree* javaTree, JProgressDisplay& pg ) { JString path; JDirInfo* info; if (!JGetTrueName(origPath, &path) || !JDirInfo::Create(path, &info)) { return; } const JSize count = info->GetEntryCount(); for (JIndex i=1; i<=count; i++) { const JDirEntry& entry = info->GetEntry(i); // If it's a directory, recurse. if (entry.IsDirectory() && recurse && !entry.IsLink() && !JIsVCSDirectory(entry.GetName())) { ScanDirectory(entry.GetFullName(), recurse, allSuffixList, symbolList, cTree, javaTree, pg); } // If it's a file ending in one of the suffixes, parse it. else if (entry.IsFile()) { JString trueName = entry.GetFullName(); time_t modTime = entry.GetModTime(); if (entry.IsWorkingLink()) { const JBoolean ok = JGetTrueName(entry.GetFullName(), &trueName); assert( ok ); const JError err = JGetModificationTime(trueName, &modTime); assert( err.OK() ); } ParseFile(trueName, allSuffixList, modTime, symbolList, cTree, javaTree); } pg.IncrementProgress(); } delete info; }
JBoolean JFSBindingList::NeedsRevert() const { time_t t; return JI2B(!itsSignalFileName.IsEmpty() && (JGetModificationTime(itsSignalFileName, &t)).OK() && itsSignalModTime != t); }
void CBFileListTable::UpdateFileInfo ( const JIndex index ) { FileInfo info = itsFileInfo->GetElement(index); info.id = GetUniqueID(); const JString& fileName = *(GetFullNameList().NthElement(index)); const JError err = JGetModificationTime(fileName, &(info.modTime)); assert_ok( err ); itsFileInfo->SetElement(index, info); if (itsFileUsage != NULL) { itsFileUsage->SetElement(index, kJTrue); } }
JBoolean CBFileNode::ParseFile ( const JString& fullName, CBFileListTable* parser, const JPtrArray<JString>& allSuffixList, CBSymbolList* symbolList, CBCTree* cTree, CBJavaTree* javaTree, CBPHPTree* phpTree, JProgressDisplay& pg ) const { time_t t; JGetModificationTime(fullName, &t); parser->ParseFile(fullName, allSuffixList, t, symbolList, cTree, javaTree, phpTree); return pg.IncrementProgress(); }
void CBFileListTable::FilesAdded ( const JOrderedSetT::ElementsInserted& info ) { const JPtrArray<JString>& fileNameList = GetFullNameList(); for (JIndex i = info.GetFirstIndex(); i <= info.GetLastIndex(); i++) { time_t t; const JError err = JGetModificationTime(*(fileNameList.NthElement(i)), &t); assert_ok( err ); itsFileInfo->InsertElementAtIndex(i, FileInfo(GetUniqueID(), t)); if (itsFileUsage != NULL) { itsFileUsage->InsertElementAtIndex(i, kJTrue); } } }
JBoolean JXSharedPrefsManager::Update() { time_t t; if (!itsSignalFileName.IsEmpty() && JGetModificationTime(itsSignalFileName, &t) == kJNoError && t != itsSignalModTime) { JBoolean isNew; return GetAll(&isNew); } else { // This exists because JCore values cannot update themsevles, // and it seems easier to toss them all in here. if ((itsOrigFocusInDockFlag != JXWindow::WillFocusFollowCursorInDock() || itsOrigCopyWhenSelectFlag != JTextEditor::WillCopyWhenSelect() || itsOrigMiddleClickWillPasteFlag != JXTEBase::MiddleButtonWillPaste() || itsOrigPWMod != JXTEBase::GetPartialWordModifier() || itsOrigCaretScrollFlag != JXTEBase::CaretWillFollowScroll() || itsOrigWindowsHomeEndFlag != JXTEBase::WillUseWindowsHomeEnd() || itsOrigAllowSpaceFlag != JXSaveFileInput::WillAllowSpace() || itsOrigMenuDisplayStyle != JXMenu::GetDisplayStyle()) && Open()) { PrivateSetFocusFollowsCursorInDock(); PrivateSetCopyWhenSelectFlag(); PrivateSetMiddleClickWillPasteFlag(); PrivateSetPartialWordModifier(); PrivateSetCaretFollowsScroll(); PrivateSetWindowsHomeEnd(); PrivateSetAllowSpaceFlag(); PrivateSetMenuDisplayStyle(); Close(kJTrue); } return kJFalse; } }
JBoolean JGetUserMountPointList ( JMountPointList* list, JMountState* state ) { time_t t; if (state != NULL && (!(JGetModificationTime(kAvailInfoName, &t)).OK() || t == state->modTime)) { return kJFalse; } list->CleanOut(); if (state != NULL) { state->modTime = t; } FILE* f = setmntent(kAvailInfoName, "r"); if (f == NULL) { return kJTrue; // did clear list } const JBoolean isRoot = JI2B( getuid() == 0 ); ACE_stat stbuf; while (const mntent* info = getmntent(f)) { if (!(isRoot || hasmntopt(info, "user") != NULL || hasmntopt(info, "users") != NULL || hasmntopt(info, "pamconsole") != NULL || (jUserOwnsDevice(info->mnt_fsname) && hasmntopt(info, "owner") != NULL)) || JIsRootDirectory(info->mnt_dir) || strcmp(info->mnt_type, MNTTYPE_SWAP) == 0) { continue; } const JMountType type = JGetUserMountPointType(info->mnt_dir, info->mnt_fsname, info->mnt_type); if (type == kJUnknownMountType || ACE_OS::stat(info->mnt_dir, &stbuf) != 0) { continue; } JFileSystemType fsType = kOtherFSType; if (JStringCompare(info->mnt_type, "vfat", kJFalse) == 0) { fsType = kVFATType; } JString* path = jnew JString(info->mnt_dir); assert( path != NULL ); JString* devicePath = jnew JString(info->mnt_fsname); assert( devicePath != NULL ); list->AppendElement(JMountPoint(path, type, stbuf.st_dev, devicePath, fsType)); } endmntent(f); return kJTrue; }
JBoolean JGetUserMountPointList ( JMountPointList* list, JMountState* state ) { time_t t; if (state != NULL && (!(JGetModificationTime(kAvailInfoName, &t)).OK() || t == state->modTime)) { return kJFalse; } list->CleanOut(); if (state != NULL) { state->modTime = t; } FILE* f = fopen(kAvailInfoName, "r"); if (f == NULL) { return kJTrue; // did clear list } const JBoolean isRoot = JI2B( getuid() == 0 ); if (isRoot) { ACE_stat stbuf; vfstab info; while (getvfsent(f, &info) == 0) { if (JIsRootDirectory(info.vfs_mountp) || strcmp(info.vfs_fstype, "swap") == 0) { continue; } const JMountType type = JGetUserMountPointType(info.vfs_mountp, info.vfs_special, info.vfs_fstype); if (type == kJUnknownMountType || ACE_OS::stat(info.vfs_mountp, &stbuf) != 0) { continue; } JFileSystemType fsType = kOtherFSType; if (JStringCompare(info.fs_vfstype, "vfat", kJFalse) == 0) { fsType = kVFATType; } JString* path = jnew JString(info.vfs_mountp); assert( path != NULL ); JString* devicePath = jnew JString(info.vfs_special); assert( devicePath != NULL ); list->AppendElement(JMountPoint(path, type, stbuf.st_dev, devicePath, fsType)); } } fclose(f); return kJTrue; }
JBoolean JGetUserMountPointList ( JMountPointList* list, JMountState* state ) { time_t t; if (state != NULL && (!(JGetModificationTime(_PATH_FSTAB, &t)).OK() || t == state->modTime)) { return kJFalse; } list->CleanOut(); if (state != NULL) { state->modTime = t; } endfsent(); const JBoolean isRoot = JI2B( getuid() == 0 ); if (isRoot) { ACE_stat stbuf; while (const fstab* info = getfsent()) { if (JIsRootDirectory(info->fs_file) || strcmp(info->fs_type, FSTAB_SW) == 0) // swap partition { continue; } const JMountType type = JGetUserMountPointType(info->fs_file, info->fs_spec, info->fs_vfstype); if (type == kJUnknownMountType || ACE_OS::stat(info->fs_file, &stbuf) != 0) { continue; } JFileSystemType fsType = kOtherFSType; if (options.Contains("vfat")) { fsType = kVFATType; } JFileSystemType fsType = kOtherFSType; if (JStringCompare(info->fs_vfstype, "vfat", kJFalse) == 0) { fsType = kVFATType; } JString* path = jnew JString(info->fs_file); assert( path != NULL ); JString* devicePath = jnew JString(info->fs_spec); assert( devicePath != NULL ); list->AppendElement(JMountPoint(path, type, stbuf.st_dev, devicePath, fsType)); } } endfsent(); return kJTrue; }
const JCharacter* JFSBindingList::Revert() { const JCharacter* userMsg = ""; // toss everything itsBindingList->CleanOut(); itsOverriddenList->CleanOut(); delete itsUserDefault; itsUserDefault = NULL; delete itsSystemDefault; itsSystemDefault = NULL; // read system bindings ifstream sysInput(kGlobalBindingsFile); if (sysInput.good()) { Load(sysInput, kJTrue); } sysInput.close(); // read user bindings JPrefsFile* file = NULL; if (!itsSignalFileName.IsEmpty() && (JPrefsFile::Create(kUserExtensionBindingRoot, &file, JFileArray::kDeleteIfWaitTimeout)).OK()) { if (file->IsEmpty()) { JString origUserFile; if (JExpandHomeDirShortcut(kOrigUserExtensionBindingFile, &origUserFile) && JFileReadable(origUserFile)) { ifstream userInput(origUserFile); if (userInput.good()) { Load(userInput, kJFalse); userMsg = JGetString("UpgradeFromVersion1::JFSBindingList"); } } } else { for (JFileVersion vers = kCurrentBindingVersion; kJTrue; vers--) { if (file->IDValid(vers)) { std::string data; file->GetData(vers, &data); std::istringstream input(data); Load(input, kJFalse); break; } if (vers == 0) { break; // check *before* decrement since unsigned } } } delete file; } if (IsEmpty()) // nothing loaded { #ifdef _J_OSX const JCharacter* data = JGetString("DefaultBindingList-OSX::JFSBindingList"); #else const JCharacter* data = JGetString("DefaultBindingList::JFSBindingList"); #endif const std::string s(data, strlen(data)); std::istringstream input(s); Load(input, kJFalse); } if (!itsSignalFileName.IsEmpty()) { JGetModificationTime(itsSignalFileName, &itsSignalModTime); } // ensure that GetDefaultCommand() will work if (itsUserDefault == NULL && itsSystemDefault == NULL) { SetDefaultCommand(kDefaultCmd, kDefaultCmdType, kDefaultSingleFile); } return userMsg; }