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.
24 /// get the current working directory
25 std::string const getcwd();
26 /// change to a directory, 0 is returned on success.
27 int chdir(std::string const & name);
28 /// Change file permissions
29 bool chmod(std::string const & file, unsigned long int mode);
31 * rename a file, returns false if it fails.
32 * It can handle renames across partitions.
34 bool rename(std::string const & from, std::string const & to);
35 /// copy a file, returns false it it fails
36 bool copy(std::string const & from, std::string const & to,
37 unsigned long int mode = (unsigned long int)-1);
38 /// generates a checksum of a file
39 unsigned long sum(std::string const & file);
40 /// FIXME: some point to this hmm ?
41 int kill(int pid, int sig);
44 /// create the given directory with the given mode
45 int mkdir(std::string const & pathname, unsigned long int mode);
46 /// unlink the given file
47 int unlink(std::string const & file);
48 /// (securely) create a temporary file in the given dir with the given prefix
49 std::string const tempName(std::string const & dir = std::string(),
50 std::string const & mask = std::string());
54 * Returns true if var is approximately equal to number with allowed error
57 * Usage: if (float_equal(var, number, 0.0001)) { }
59 * This will check if 'var' is approx. equal to 'number' with error of 1/1000
61 inline bool float_equal(double var, double number, double error)
63 return (number - error <= var && var <= number + error);
66 } // namespace support
69 #endif /* LYX_LIB_H */