4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
21 string const CreateBufferTmpDir(string const & pathfor = string());
23 /// Creates directory. Returns true on succes.
24 bool createDirectory(string const & name, int permissions);
27 string const CreateLyXTmpDir(string const & deflt);
30 int DestroyBufferTmpDir(string const & tmpdir);
33 int DestroyLyXTmpDir(string const & tmpdir);
35 /** Find file by searching several directories.
36 Uses a string of paths separated by ";"s to find a file to open.
37 Can't cope with pathnames with a ';' in them. Returns full path to file.
38 If path entry begins with $$LyX/, use system_lyxdir.
39 If path entry begins with $$User/, use user_lyxdir.
40 Example: "$$User/doc;$$LyX/doc".
42 string const FileOpenSearch(string const & path, string const & name,
43 string const & ext = string());
45 /** Returns the real name of file name in directory path, with optional
47 The file is searched in the given path (unless it is an absolute
48 file name), first directly, and then with extension .ext (if given).
50 string const FileSearch(string const & path, string const & name,
51 string const & ext = string());
53 /// Returns a vector of all files in directory dir having extension ext.
54 std::vector<string> const DirList(string const & dir,
55 string const & ext = string());
57 /** Is directory read only?
62 bool IsDirWriteable (string const & path);
64 /** Is a file readable ?
65 Returns true if the file `path' is readable.
67 bool IsFileReadable (string const & path);
69 /** Is file read only?
73 -1: error (doesn't exist, no access, anything else)
75 int IsFileWriteable (string const & path);
78 bool IsLyXFilename(string const & filename);
81 bool IsSGMLFilename(string const & filename);
83 /** Returns the path of a library data file.
84 Search the file name.ext in the subdirectory dir of
87 \item build_lyxdir (if not empty)
90 The third parameter `ext' is optional.
92 string const LibFileSearch(string const & dir, string const & name,
93 string const & ext = string());
95 /** Same as LibFileSearch(), but tries first to find an
96 internationalized version of the file by prepending $LANG_ to the
100 i18nLibFileSearch(string const & dir, string const & name,
101 string const & ext = string());
103 /** Takes a command with arguments as input and tries to see whether
104 the command itself can be found in one of the scripts/ directories.
105 If it is found, return the command with fully qualified script name,
106 either return it unchanged */
107 string const LibScriptSearch(string const & command);
110 string const GetEnv(string const & envname);
112 /// A helper function.
113 string const GetEnvPath(string const & name);
116 bool PutEnv(string const & envstr);
119 bool PutEnvPath(string const & envstr);
121 /// Substitutes active latex characters with underscores in filename
122 string const MakeLatexName(string const & file);
124 /// Put the name in quotes suitable for the current shell
125 string const QuoteName(string const & file);
127 /// Add a filename to a path. Any path from filename is stripped first.
128 string const AddName(string const & path, string const & fname);
130 /// Append sub-directory(ies) to path in an intelligent way
131 string const AddPath(string const & path, string const & path2);
133 /** Change extension of oldname to extension.
134 If oldname does not have an extension, it is appended.
135 If the extension is empty, any extension is removed from the name.
138 ChangeExtension(string const & oldname, string const & extension);
140 /// Return the extension of the file (not including the .)
141 string const GetExtension(string const & name);
143 /// Return the type of the file as an extension from contents
144 string const getExtFromContents(string const & name);
146 /// check for zipped file
147 bool zippedFile(string const & name);
150 string const unzipFile(string const & zipped_file);
152 /// Returns true is path is absolute
153 bool AbsolutePath(string const & path);
155 /// Create absolute path. If impossible, don't do anything
156 string const ExpandPath(string const & path);
158 /** Convert relative path into absolute path based on a basepath.
159 If relpath is absolute, just use that.
160 If basepath doesn't exist use CWD.
162 string const MakeAbsPath(string const & RelPath = string(),
163 string const & BasePath = string());
165 /** Creates a nice compact path for displaying. The parameter
166 threshold, if given, specifies the maximal length of the path.
169 MakeDisplayPath(string const & path, unsigned int threshold = 1000);
171 /** Makes relative path out of absolute path.
172 If it is deeper than basepath,
173 it's easy. If basepath and abspath share something (they are all deeper
174 than some directory), it'll be rendered using ..'s. If they are completely
175 different, then the absolute path will be used as relative path
176 WARNING: the absolute path and base path must really be absolute paths!!!
179 MakeRelPath(string const & abspath, string const & basepath);
181 /// Strip filename from path name
182 string const OnlyPath(string const & fname);
184 /// Normalize a path. Constracts path/../path
185 string const NormalizePath(string const & path);
187 /// Strips path from filename
188 string const OnlyFilename(string const & fname);
190 /// Get the contents of a file as a huge string
191 string const GetFileContents(string const & fname);
193 /** Check and Replace Environmentvariables ${NAME} in Path.
194 Replaces all occurences of these, if they are found in the
196 Variables are defined by Var := '${' [a-zA-Z_][a-zA-Z_0-9]* '}'
198 string const ReplaceEnvironmentPath(string const & path);
200 /* Set \c link to the path \c file points to as a symbolic link.
201 If \c resolve is true, then \c link is an absolute path
202 Returns true if successful */
203 bool LyXReadLink(string const & file, string & link, bool resolve = false);
205 /// Uses kpsewhich to find tex files
206 string const findtexfile(string const & fil, string const & format);
208 /// remove the autosave-file and give a Message if it can't be done
209 void removeAutosaveFile(string const & filename);
211 /// read the BoundingBox entry from a ps/eps/pdf-file
212 string const readBB_from_PSFile(string const & file);
214 typedef std::pair<int, string> cmd_ret;
216 cmd_ret const RunCommand(string const & cmd);