#define LYX_FILETOOL_H
#include "support/docstring.h"
-#include "support/filename.h"
+#include "support/FileName.h"
#include <vector>
#include <utility>
namespace lyx {
namespace support {
-/// remove directory and all contents, returns true on success
-bool destroyDir(FileName const & tmpdir);
-
/// Creates the per buffer temporary directory
std::string const createBufferTmpDir();
-/// Creates directory. Returns true on success
-bool createDirectory(std::string const & name, int permissions);
-
/** Creates the global LyX temp dir.
\p deflt can be an existing directory name. In this case a new directory
inside \p deflt is created. If \p deflt does not exist yet, \p deflt is
std::string const & ext = std::string(),
search_mode mode = standard_mode);
-/// Returns a vector of all files in directory dir having extension ext.
-std::vector<FileName> const dirList(FileName const & dir,
- std::string const & ext = std::string());
-
-/** Is directory read only?
- returns
- true: dir writeable
- false: not writeable
-*/
-bool isDirWriteable(FileName const & path);
-
-/** Is a file readable ?
- Returns true if the file `path' is readable.
- */
-bool isFileReadable(FileName const & path);
-
///
bool isLyXFilename(std::string const & filename);
///
bool isSGMLFilename(std::string const & filename);
+///
+bool isValidLaTeXFilename(std::string const & filename);
+
/** Returns the path of a library data file.
Search the file name.ext in the subdirectory dir of
-# user_lyxdir
latex_path_dots dots = LEAVE_DOTS);
/// Substitutes active latex characters with underscores in filename
-std::string const makeLatexName(std::string const & file);
+FileName const makeLatexName(FileName const & file);
/** Put the name in quotes suitable for the current shell or python,
depending on \p style. */
/// Return the extension of the file (not including the .)
std::string const getExtension(std::string const & name);
-/** Guess the file format name (as in Format::name()) from contents.
- Normally you don't want to use this directly, but rather
- Formats::getFormatFromFile().
- */
-std::string const getFormatFromContents(FileName const & name);
-
-/// check for zipped file
-bool zippedFile(FileName const & name);
-
/** \return the name that LyX will give to the unzipped file \p zipped_file
if the second argument of unzipFile() is empty.
*/
Will overwrite an already existing unzipped file without warning.
*/
FileName const unzipFile(FileName const & zipped_file,
- std::string const & unzipped_file = std::string());
+ std::string const & unzipped_file = std::string());
/// Returns true is path is absolute
bool absolutePath(std::string const & path);
different, then the absolute path will be used as relative path
WARNING: the absolute path and base path must really be absolute paths!!!
*/
-std::string const
-makeRelPath(std::string const & abspath, std::string const & basepath);
+docstring const
+makeRelPath(docstring const & abspath, docstring const & basepath);
/// Strip filename from path name
std::string const onlyPath(std::string const & fname);
-/** Normalize a path. Constracts path/../path
- * Also converts paths like /foo//bar ==> /foo/bar
- */
-std::string const normalizePath(std::string const & path);
-
/// Strips path from filename
std::string const onlyFilename(std::string const & fname);
-/// Get the contents of a file as a huge std::string
-std::string const getFileContents(FileName const & fname);
-
/** Check and Replace Environmentvariables ${NAME} in Path.
Replaces all occurences of these, if they are found in the
environment.
*/
std::string const replaceEnvironmentPath(std::string const & path);
-/* Set \c link to the path \c file points to as a symbolic link.
- If \c resolve is true, then \c link is an absolute path
- Returns true if successful */
-bool readLink(std::string const & file,
- std::string & link,
- bool resolve = false);
+/** Set \c link to the path \c file points to as a symbolic link.
+ \return true if successful.
+ */
+bool readLink(FileName const & file, FileName & link);
/**
* Search a TeX file in all locations the latex compiler would search it,
} // namespace support
} // namespace lyx
+/// The following functions are implemented in minizip/zipunzip.cpp, and are not in
+/// the lyx::support namespace
+
+/// zip several files to a zipfile. In-zip filenames are also specified
+bool zipFiles(std::string const & zipfile, std::vector<std::pair<std::string, std::string> > const & files);
+
+/// Unzip a zip file to a directory
+bool unzipToDir(std::string const & zipfile, std::string const & path);
+
+
#endif