]> git.lyx.org Git - lyx.git/blobdiff - src/support/filetools.h
forward port latex_path quoting fix from 1.3
[lyx.git] / src / support / filetools.h
index 1f3fe1fd59f9c8b565fb1c394bd22bff6b30c50f..fba202e24f3b0fc530708d9e9e62532e588bfd8e 100644 (file)
@@ -19,8 +19,8 @@
 namespace lyx {
 namespace support {
 
-/// remove directory and all contents, returns 0 on success
-int destroyDir(std::string const & tmpdir);
+/// remove directory and all contents, returns true on success
+bool destroyDir(std::string const & tmpdir);
 
 /// Creates the per buffer temporary directory
 std::string const createBufferTmpDir();
@@ -70,14 +70,6 @@ bool IsDirWriteable (std::string const & path);
  */
 bool IsFileReadable (std::string const & path);
 
-/** Is file read only?
-  returns
-    1: read-write
-    0: read_only
-   -1: error (doesn't exist, no access, anything else)
-  */
-int IsFileWriteable (std::string const & path);
-
 ///
 bool IsLyXFilename(std::string const & filename);
 
@@ -85,12 +77,10 @@ bool IsLyXFilename(std::string const & filename);
 bool IsSGMLFilename(std::string const & filename);
 
 /** Returns the path of a library data file.
-  Search the file name.ext in the subdirectory dir of
-  \begin{enumerate}
-    \item user_lyxdir
-    \item build_lyxdir (if not empty)
-    \item system_lyxdir
-  \end{enumerate}
+    Search the file name.ext in the subdirectory dir of
+      -# user_lyxdir
+      -# build_lyxdir (if not empty)
+      -# system_lyxdir
     The third parameter `ext' is optional.
 */
 std::string const LibFileSearch(std::string const & dir, std::string const & name,
@@ -112,34 +102,24 @@ i18nLibFileSearch(std::string const & dir, std::string const & name,
  */
 std::string const LibScriptSearch(std::string const & command);
 
-///
-std::string const GetEnv(std::string const & envname);
-
-/** Return the contents of the environment variable \c name,
- *  split using the OS-dependent token separating elements.
- *  Each element is then passed through os::internal_path to
- *  guarantee that it is in the form of a unix-stype path.
- *  If the environment variable is not set, then returns an empty vector.
- */
-std::vector<std::string> const getEnvPath(std::string const & name);
-
-/** Set the contents of the environment variable \c name
- *  using the paths stored in the \c env vector.
- *  Each element is passed through os::external_path.
- */
-void setEnvPath(std::string const & name, std::vector<std::string> const & env);
-
-/** Prepend a list of paths to that returned by the environment variable.
- *  Identical paths occurring later in the list are removed.
- *  @param name the name of the environment variable.
- *  @prefix the list of paths in OS-native syntax.
- *  Eg "/foo/bar:/usr/bin:/usr/local/bin" on *nix,
- *     "C:\foo\bar;C:\windows" on Windows.
+/** @param path a file path in internal_path format. Ie, directories
+ *  are indicated by '/', not by '\'.
+ *
+ *  Manipulates @c path into a form suitable for inclusion in a LaTeX
+ *  document.
+ *  If @c path contains LaTeX special characters, these are escaped.
+ *  Eg, '~' -> '\\string~'
+ *  If @c path contains spaces, then the returned path is enclosed in
+ *  "-quotes. This last fix will lead to successful compiliation of the
+ *  LaTeX file only if a sufficiently modern LaTeX compiler is used.
+ *  If @c exclude_extension is true the extension is left outside the quotes.
+ *  This is needed for pdfeTeX, Version 3.141592-1.21a-2.2 (Web2C 7.5.4)
+ *  (format=pdflatex 2005.4.11) in combination with
+ *  pdftex.def 2002/06/19 v0.03k graphics/color for pdftex:
+ *  It does not recognize the file extension if it is inside the quotes.
  */
-void prependEnvPath(std::string const & name, std::string const & prefix);
-
-/// Set an environment variable using a string of the form "name=FOO".
-bool putEnv(std::string const & envstr);
+std::string const latex_path(std::string const & path,
+                             bool exclude_extension = false)
 
 /// Substitutes active latex characters with underscores in filename
 std::string const MakeLatexName(std::string const & file);