Attached -- Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. (T. Jefferson)
? t ? frontends/qt2/xforms/Makefile.in ? frontends/xforms/.FormFiledialog.C.swp ? mathed/.math_metricsinfo.h.swp ? mathed/.math_metricsinfo.C.swp ? mathed/.math_cursor.C.swp ? support/t Index: frontends/xforms/FormFiledialog.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormFiledialog.C,v retrieving revision 1.26 diff -u -p -r1.26 FormFiledialog.C --- frontends/xforms/FormFiledialog.C 16 Jul 2002 08:31:21 -0000 1.26 +++ frontends/xforms/FormFiledialog.C 16 Jul 2002 11:37:15 -0000 @@ -13,7 +13,6 @@ #include <cstdlib> #include <pwd.h> #include <grp.h> -//#include <cstring> #include <map> #include <algorithm> @@ -187,8 +186,7 @@ void FileDialog::Private::Reread() // Opens directory DIR * dir = ::opendir(directory_.c_str()); if (!dir) { - Alert::err_alert(_("Warning! Couldn't open directory."), - directory_); + Alert::err_alert(_("Warning! Couldn't open directory."), directory_); directory_ = lyx::getcwd(); dir = ::opendir(directory_.c_str()); } @@ -204,13 +202,13 @@ void FileDialog::Private::Reread() // Splits complete directory name into directories and compute depth depth_ = 0; string line, Temp; - char szMode[15]; + string mode; string File = directory_; if (File != "/") { File = split(File, Temp, '/'); } while (!File.empty() || !Temp.empty()) { - string dline = "@b"+line + Temp + '/'; + string dline = "@b" + line + Temp + '/'; fl_add_browser_line(file_dlg_form_->List, dline.c_str()); File = split(File, Temp, '/'); line += ' '; @@ -220,16 +218,16 @@ void FileDialog::Private::Reread() // Parses all entries of the given subdirectory time_t curTime = time(0); rewinddir(dir); - while (dirent * pDirEntry = readdir(dir)) { + while (dirent * entry = readdir(dir)) { bool isLink = false, isDir = false; // If the pattern doesn't start with a dot, skip hidden files if (!mask_.empty() && mask_[0] != '.' && - pDirEntry->d_name[0] == '.') + entry->d_name[0] == '.') continue; // Gets filename - string fname = pDirEntry->d_name; + string fname = entry->d_name; // Under all circumstances, "." and ".." are not wanted if (fname == "." || fname == "..") @@ -244,10 +242,10 @@ void FileDialog::Private::Reread() if (!fileInfo.isOK()) continue; - fileInfo.modeString(szMode); - unsigned int nlink = fileInfo.getNumberOfLinks(); - string user = lyxUserCache.find(fileInfo.getUid()); - string group = lyxGroupCache.find(fileInfo.getGid()); + mode = fileInfo.modeString(); + unsigned int const nlink = fileInfo.getNumberOfLinks(); + string const user = lyxUserCache.find(fileInfo.getUid()); + string const group = lyxGroupCache.find(fileInfo.getGid()); time_t modtime = fileInfo.getModificationTime(); string Time = ctime(&modtime); @@ -265,21 +263,22 @@ void FileDialog::Private::Reread() Time.erase(16, string::npos); } - string Buffer = string(szMode) + ' ' + + string buffer = mode + ' ' + tostr(nlink) + ' ' + user + ' ' + group + ' ' + Time.substr(4, string::npos) + ' '; - Buffer += pDirEntry->d_name; - Buffer += fileInfo.typeIndicator(); + buffer += entry->d_name; + buffer += fileInfo.typeIndicator(); - if ((isLink = fileInfo.isLink())) { + isLink = fileInfo.isLink(); + if (isLink) { string Link; if (LyXReadLink(File, Link)) { - Buffer += " -> "; - Buffer += Link; + buffer += " -> "; + buffer += Link; // This gives the FileType of the file that // is really pointed too after resolving all @@ -289,7 +288,7 @@ void FileDialog::Private::Reread() // JV 199902 fileInfo.newFile(File); if (fileInfo.isOK()) - Buffer += fileInfo.typeIndicator(); + buffer += fileInfo.typeIndicator(); else continue; } @@ -308,14 +307,14 @@ void FileDialog::Private::Reread() DirEntry tmp; // Note ls_entry_ is an string! - tmp.ls_entry_ = Buffer; + tmp.ls_entry_ = buffer; // creates used name string temp = fname; if (isDir) temp += '/'; tmp.name_ = temp; // creates displayed name - temp = pDirEntry->d_name; + temp = entry->d_name; if (isLink) temp += '@'; else Index: support/FileInfo.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/FileInfo.C,v retrieving revision 1.16 diff -u -p -r1.16 FileInfo.C --- support/FileInfo.C 16 Jul 2002 10:05:52 -0000 1.16 +++ support/FileInfo.C 16 Jul 2002 11:37:15 -0000 @@ -90,7 +90,7 @@ namespace { -/// builds 'rwx' string describing file access rights +// builds 'rwx' string describing file access rights void flagRWX(mode_t i, char * str) { str[0] = (i & S_IRUSR) ? 'r' : '-'; @@ -98,7 +98,7 @@ void flagRWX(mode_t i, char * str) str[2] = (i & S_IXUSR) ? 'x' : '-'; } -/// updates mode string to match suid/sgid/sticky bits +// updates mode string to match suid/sgid/sticky bits void setSticky(mode_t i, char * str) { #ifdef S_ISUID @@ -115,6 +115,34 @@ void setSticky(mode_t i, char * str) #endif } +// returns a letter describing a file type (ls style) +char typeLetter(mode_t i) +{ +#ifdef S_ISBLK + if (S_ISBLK(i)) return 'b'; +#endif + if (S_ISCHR(i)) return 'c'; + if (S_ISDIR(i)) return 'd'; + if (S_ISREG(i)) return '-'; +#ifdef S_ISFIFO + if (S_ISFIFO(i)) return 'p'; +#endif +#ifdef S_ISLNK + if (S_ISLNK(i)) return 'l'; +#endif +#ifdef S_ISSOCK + if (S_ISSOCK(i)) return 's'; +#endif +#ifdef S_ISMPC + if (S_ISMPC(i)) return 'm'; +#endif +#ifdef S_ISNWK + if (S_ISNWK(i)) return 'n'; +#endif + return '?'; +} + + } // namespace anon @@ -181,26 +209,26 @@ FileInfo & FileInfo::newFile(int fildes) // should not be in FileInfo -char const * FileInfo::typeIndicator() const +char FileInfo::typeIndicator() const { lyx::Assert(isOK()); if (S_ISDIR(buf_.st_mode)) - return "/"; + return '/'; #ifdef S_ISLNK if (S_ISLNK(buf_.st_mode)) - return "@"; + return '@'; #endif #ifdef S_ISFIFO if (S_ISFIFO(buf_.st_mode)) - return "|"; + return '|'; #endif #ifdef S_ISSOCK if (S_ISSOCK(buf_.st_mode)) - return "="; + return '='; #endif if (S_ISREG(buf_.st_mode) && (buf_.st_mode & (S_IEXEC | S_IXGRP | S_IXOTH))) - return "*"; - return ""; + return '*'; + return ' '; } @@ -212,45 +240,17 @@ mode_t FileInfo::getMode() const // should not be in FileInfo -void FileInfo::modeString(char * str) const +string FileInfo::modeString() const { - str[0] = typeLetter(); + lyx::Assert(isOK()); + char str[11]; + str[0] = typeLetter(buf_.st_mode); flagRWX((buf_.st_mode & 0700) << 0, &str[1]); flagRWX((buf_.st_mode & 0070) << 3, &str[4]); flagRWX((buf_.st_mode & 0007) << 6, &str[7]); - lyx::Assert(isOK()); setSticky(buf_.st_mode, str); str[10] = 0; -} - - -// should not be in FileInfo -char FileInfo::typeLetter() const -{ - lyx::Assert(isOK()); - -#ifdef S_ISBLK - if (S_ISBLK(buf_.st_mode)) return 'b'; -#endif - if (S_ISCHR(buf_.st_mode)) return 'c'; - if (S_ISDIR(buf_.st_mode)) return 'd'; - if (S_ISREG(buf_.st_mode)) return '-'; -#ifdef S_ISFIFO - if (S_ISFIFO(buf_.st_mode)) return 'p'; -#endif -#ifdef S_ISLNK - if (S_ISLNK(buf_.st_mode)) return 'l'; -#endif -#ifdef S_ISSOCK - if (S_ISSOCK(buf_.st_mode)) return 's'; -#endif -#ifdef S_ISMPC - if (S_ISMPC(buf_.st_mode)) return 'm'; -#endif -#ifdef S_ISNWK - if (S_ISNWK(buf_.st_mode)) return 'n'; -#endif - return '?'; + return str; } Index: support/FileInfo.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/FileInfo.h,v retrieving revision 1.21 diff -u -p -r1.21 FileInfo.h --- support/FileInfo.h 16 Jul 2002 10:05:52 -0000 1.21 +++ support/FileInfo.h 16 Jul 2002 11:37:15 -0000 @@ -37,12 +37,10 @@ public: /** Get information about file. If link is true, the information is about the link itself, not the file that is obtained by tracing the links. */ - explicit - FileInfo(string const & path, bool link = false); + explicit FileInfo(string const & path, bool link = false); /// File descriptor - explicit - FileInfo(int fildes); + explicit FileInfo(int fildes); /// Query a new file FileInfo & newFile(string const & path, bool link = false); @@ -51,16 +49,13 @@ public: FileInfo & newFile(int fildes); /// Returns a character describing file type (ls -F) - char const * typeIndicator() const; + char typeIndicator() const; /// File protection mode mode_t getMode() const; /// Constructs standard mode string (ls style) - void modeString(char * str) const; - - /// returns a letter describing a file type (ls style) - char typeLetter() const; + string modeString() const; /// time_t getModificationTime() const;