]> git.lyx.org Git - lyx.git/blob - src/support/lyxlib.h
support for wasy symbols
[lyx.git] / src / support / lyxlib.h
1 // -*- C++ -*-
2 /**
3  * \file lyxlib.h
4  * Copyright 1995-2002 the LyX Team
5  * Read the file COPYING
6  *
7  * A selection of useful system functions made
8  * handy for C++ usage.
9  *
10  * \author unknown
11  */
12
13 #ifndef LYX_LIB_H
14 #define LYX_LIB_H
15
16 #include "LString.h"
17
18 namespace lyx {
19
20 /// get the current working directory
21 string const getcwd();
22 /// change to a directory, 0 is returned on success.
23 int chdir(string const & name);
24 /**
25  * rename a file, returns false if it fails. 
26  * It can handle renames across partitions.
27  */
28 bool rename(string const & from, string const & to);
29 /// copy a file, returns false it it fails
30 bool copy(string const & from, string const & to);
31 /// generates a checksum of a file
32 unsigned long sum(string const & file);
33 /// FIXME: some point to this hmm ?
34 int kill(int pid, int sig);
35 /// FIXME: same here
36 void abort();
37 /// create the given directory with the given mode
38 int mkdir(string const & pathname, unsigned long int mode);
39 /// put a C string into the environment
40 int putenv(char const * str);
41 /// unlink the given file
42 int unlink(string const & file);
43 /// remove the given directory
44 int rmdir(string const & file);
45 /// convert the given string to an integer
46 int atoi(string const & nstr);
47 /// (securely) create a temporary file in the given dir with the given prefix
48 string const tempName(string const & dir = string(),
49                       string const & mask = string());
50
51
52 /**
53  * Returns true if var is approximately equal to number with allowed error
54  * of 'error'.
55  *
56  * Usage: if (float_equal(var, number, 0.0001)) { }
57  *
58  * This will check if 'var' is approx. equal to 'number' with error of 1/1000
59  */
60 inline bool float_equal(float var, float number, float error)
61 {
62         return (number - error <= var && var <= number + error);
63 }
64
65 } // namespace lyx
66  
67 #endif /* LYX_LIB_H */