4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * A selection of useful system functions made
10 * \author Lars Gullik Bjønnes
12 * Full author contact details are available in file CREDITS.
18 #include "support/filename.h"
26 /// get the current working directory
27 FileName const getcwd();
28 /// change to a directory, 0 is returned on success.
29 int chdir(FileName const & name);
30 /// Change file permissions
31 bool chmod(FileName const & file, unsigned long int mode);
33 * rename a file, returns false if it fails.
34 * It can handle renames across partitions.
36 bool rename(FileName const & from, FileName const & to);
37 /// copy a file, returns false it it fails
38 bool copy(FileName const & from, FileName const & to,
39 unsigned long int mode = (unsigned long int)-1);
40 /// generates a checksum of a file
41 unsigned long sum(FileName const & file);
42 /// FIXME: some point to this hmm ?
43 int kill(int pid, int sig);
46 /// create the given directory with the given mode
47 int mkdir(FileName const & pathname, unsigned long int mode);
48 /// unlink the given file
49 int unlink(FileName const & file);
50 /// (securely) create a temporary file in the given dir with the given mask
51 /// \p mask must be in filesystem encoding
52 FileName const tempName(FileName const & dir = FileName(),
53 std::string const & mask = std::string());
57 * Returns true if var is approximately equal to number with allowed error
60 * Usage: if (float_equal(var, number, 0.0001)) { }
62 * This will check if 'var' is approx. equal to 'number' with error of 1/1000
64 inline bool float_equal(double var, double number, double error)
66 return (number - error <= var && var <= number + error);
69 } // namespace support
72 #endif /* LYX_LIB_H */