Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TRAIL_UnixUtils.H
Go to the documentation of this file.
1 /* *******************************************************************
2  * Rocstar Simulation Suite *
3  * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4  * *
5  * Illinois Rocstar LLC *
6  * Champaign, IL *
7  * www.illinoisrocstar.com *
8  * sales@illinoisrocstar.com *
9  * *
10  * License: See LICENSE file in top level of distribution package or *
11  * http://opensource.org/licenses/NCSA *
12  *********************************************************************/
13 /* *******************************************************************
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17  * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21  * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22  *********************************************************************/
23 #ifndef _UNIX_UTIL_H_
24 #define _UNIX_UTIL_H_
25 
26 #include <ostream>
27 #include <sys/types.h>
28 #include <dirent.h>
29 #include <sys/stat.h>
30 #include <unistd.h>
31 
32 
33 std::string TRAIL_CWD(void);
34 void TRAIL_SafeRemove(const std::string &fname,const std::string &ext);
35 int TRAIL_CD(const std::string &path,std::ostream * = NULL);
36 bool TRAIL_FILEEXISTS(const std::string &fname);
37 bool TRAIL_ISDIR(const std::string &fname);
38 bool TRAIL_ISLINK(const std::string &fname);
39 int TRAIL_CreateDirectory(const std::string &fname);
40 std::string TRAIL_ResolveLink(const std::string &path);
41 std::string ResolveLink(const std::string &path);
42 class Directory : public std::vector<std::string>
43 {
44 protected:
45  std::string _path;
46  bool _good;
47  DIR *_dir;
48 public:
49  Directory(const std::string &s = "");
50  ~Directory();
51  int open(const std::string &s = "");
52  void close();
53  operator void* ();
54  bool operator ! ();
55 };
56 
57 #endif
58 
59 
60 
61 
62 
63 
bool TRAIL_FILEEXISTS(const std::string &fname)
DIR * _dir
Definition: Directory.H:31
double s
Definition: blastest.C:80
bool operator!()
Definition: Directory.C:56
~Directory()
Definition: Directory.C:45
int TRAIL_CD(const std::string &path, std::ostream *=NULL)
std::string TRAIL_ResolveLink(const std::string &path)
bool TRAIL_ISDIR(const std::string &fname)
int open(const std::string &s="")
Definition: Directory.C:69
void TRAIL_SafeRemove(const std::string &fname, const std::string &ext)
void close()
Definition: Directory.C:62
Directory(const std::string &s="")
Definition: Directory.C:31
std::string TRAIL_CWD(void)
std::string _path
Definition: Directory.H:29
bool _good
Definition: Directory.H:30
int TRAIL_CreateDirectory(const std::string &fname)
bool TRAIL_ISLINK(const std::string &fname)
std::string ResolveLink(const std::string &path)