/** Use this if you want to rebind the FilePtr to another file.
*/
FilePtr& reopen(LString const &name, file_mode mode) { // close the file it it is already open
close(); // Now open the file.
do_open(name, mode);
return *this;
} /** Close the file. Usethiswithsomecarefullness.Afterithasbeenused theFilePtrisunusable.Onlyuseitifitisimportant thatthefileisclosedbeforetheFilePtrgoesout
of scope. */ int close() { if (p) { int result = fclose(p);
p = 0; return result;
} else return0;
} /// automatic converson to FILE* if that is needed. operator FILE*() { return p; } ///
FilePtr& operator=(FILE *f) { p=f; return *this;} ///
FILE *operator()() { return p; } private: /// void do_open(LString const &name, file_mode mode) { char modestr[3];
switch(mode) { // do appropiate #ifdef here so support EMX #ifndef __EMX__ case read: strcpy(modestr, "r"); break; case write: strcpy(modestr, "w"); break; #else case read: strcpy(modestr,"rt"); break; // Can read both DOS & UNIX text files. case write: strcpy(modestr,"w"); break; // Write UNIX text files. #endif
case update: strcpy(modestr, "r+"); break; case truncate: strcpy(modestr, "w+"); break;
} // Should probably be rewritten to use open(2) if((p = fopen(name.c_str(), modestr))) { // file succesfully opened. if (fcntl(fileno(p),F_SETFD,FD_CLOEXEC) == -1) {
p = 0;
}
} else { // we have an error let's check what it is. switch(errno) { case EINVAL: // Internal LyX error.
lyxerr.print("FilePtr: Wrong parameter given to fopen."); break; default: // unknown error break;
}
}
} /// void init() { p = 0; } ///
FILE *p;
};
/** Returns the real name of file name in directory path, with optional extensionext. Thefileissearchedinthegivenpath(unlessitisanabsolute filename),firstdirectly,andthenwithextension.ext(ifgiven).
*/
LString FileSearch(LString const & path, LString const & name,
LString const & ext = LString());
/** Is directory read only? returns 1:dirwriteable 0:notwriteable -1:error-couldn'tfindout,orunsure
*/ int IsDirWriteable (LString const & path);
/** Is a file readable ? Returnstrueifthefile`path'isreadable.
*/ bool IsFileReadable (LString const & path);
/** Is file read only? returns 1:read-write 0:read_only -1:error(doesn'texist,noaccess,anythingelse)
*/ int IsFileWriteable (LString const & path);
/** Returns the path of a library data file. Searchthefilename.extinthesubdirectorydirof \begin{enumerate} \itemuser_lyxdir \itembuild_lyxdir(ifnotempty) \itemsystem_lyxdir \end{enumerate} Thethirdparameter`ext'isoptional.
*/
LString LibFileSearch(LString const & dir, LString const & name,
LString const & ext = LString());
/** Same as LibFileSearch(), but tries first to find an internationalizedversionofthefilebyprepending$LANG_tothe name
*/
LString i18nLibFileSearch(LString const & dir, LString const & name,
LString const & ext = LString());
/// Substitutes spaces with underscores in filename (and path)
LString SpaceLess(LString const & file);
/** Returns an unique name to be used as a temporary file. If given, 'mask'shouldtheprefixtothetemporaryfile,therestofthe temporaryfilenamewillbemadefromthepidandthreeletters.
*/
LString TmpFileName(LString const & dir = LString(),
LString const & mask = "lyx_tmp");
/// Is a filename/path absolute? bool AbsolutePath(LString const &path);
/// Add a filename to a path. Any path from filename is stripped first.
LString AddName(LString const &Path, LString const &Filename);
/// Append sub-directory(ies) to path in an intelligent way
LString AddPath(LString const & path, LString const & path2);
/** Convert relative path into absolute path based on a basepath. Ifrelpathisabsolute,justusethat. Ifbasepathdoesn'texistuseCWD.
*/
LString MakeAbsPath(LString const &RelPath = LString(),
LString const &BasePath = LString());
/** Creates a nice compact path for displaying. The parameter threshold,ifgiven,specifiesthemaximallengthofthepath.
*/
LString MakeDisplayPath(LString const & path, int threshold=1000);
/** Makes relative path out of absolute path. Ifitisdeeperthanbasepath, it'seasy.Ifbasepathandabspathsharesomething(theyarealldeeper thansomedirectory),it'llberenderedusing..'s.Iftheyarecompletely different,thentheabsolutepathwillbeusedasrelativepath WARNING:theabsolutepathandbasepathmustreallybeabsolutepaths!!!
*/
LString MakeRelPath(LString const & abspath, LString const & basepath);
/// Strip filename from path name
LString OnlyPath(LString const &Filename);
/// Normalize a path. Constracts path/../path
LString NormalizePath(LString const &path);
/// Strips path from filename
LString OnlyFilename(LString const &Filename);
/** Check and Replace Environmentvariables ${NAME} in Path. Replacesalloccurencesofthese,iftheyarefoundinthe environment. VariablesaredefinedbyVar:='${'[a-zA-Z_][a-zA-Z_0-9]*'}'
*/
LString ReplaceEnvironmentPath(LString const &path);
#endif
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet am 2026-09-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.