boolean Browser::openFile(char *filenm) { struct STATSTRUCT statb; char title[512]; this->from = new std::ifstream(filenm); if(!this->from) { WarningMessage("File open failed for file %s", filenm); return FALSE; } if(STATFUNC(filenm, &statb) == -1) { // stat failed return FALSE; } this->file_size = statb.st_size; // // Clear any existing mark // this->marker_pos = 0; this->marker_char[0] = '\0'; this->page_start = 0; this->page_start_line_no = 0; this->loadBuffer(0); title[0] = '\0'; strcat(title, "File Browser: "); strcat(title, filenm); this->setWindowTitle(title); return TRUE; }
void ColormapEditor::manage() { this->DXWindow::manage(); // // If the .net had the name of a .cm file and this is the first time // we're opening this editor, then make sure the values form the .cm // file are fed back into the node (they were installed in // createWorkArea()). // const char *name; if (this->neverManaged && (name = this->colormapNode->getNetSavedCMFilename())) { struct STATSTRUCT statbuf; if (STATFUNC(name,&statbuf) == 0) { // File exists XmColorMapEditorRead(this->colormapEditor,(char*)name); } else { WarningMessage("Can't locate color map file '%s', " "using default map",name); } } this->handleStateChange(); this->neverManaged = FALSE; }
static void _FileIterator_MapOsDataToFileInfo (FileIterator::FileInfo& info, const StringA& strDir, const char* pszFileName) { #if defined(GLB_PLATFORM_CYGWIN) #define STATSTRUCT struct stat #define STATFUNC ::stat #else #define STATSTRUCT struct stat64 #define STATFUNC ::stat64 #endif STATSTRUCT stats; // name info.strName = pszFileName; // reset other members first info.eType = FileIterator::TYPE_UNKNOWN; info.uiSize = 0; info.nModifTime = 0; // get file stats if needed if (info.fQueryFlags != 0) { StringA strFilePath; _FileIterator_BuildFilePathIfNeeded(strFilePath, strDir, info.strName); if (STATFUNC(strFilePath, &stats) != 0) { GLB_ASSERT(0); // error while calling stat() from FileIterator ! return; } } // type if ((info.fQueryFlags & FileIterator::QUERY_TYPE) != 0) { if (S_ISDIR(stats.st_mode)) info.eType = FileIterator::TYPE_DIRECTORY; else if (S_ISREG(stats.st_mode)) info.eType = FileIterator::TYPE_FILE; else if (S_ISLNK(stats.st_mode)) info.eType = FileIterator::TYPE_SYMLINK; } // size if ((info.fQueryFlags & FileIterator::QUERY_SIZE) != 0) { GLB_ASSERT(sizeof(info.uiSize) == sizeof(stats.st_size)); info.uiSize = stats.st_size; } // modification time if ((info.fQueryFlags & FileIterator::QUERY_MODIFTIME) != 0) { GLB_ASSERT(sizeof(info.nModifTime) == sizeof(stats.st_mtime)); info.nModifTime = stats.st_mtime; } #undef STATSTRUCT #undef STATFUNC }