YARP
Yet Another Robot Platform
Os.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2018 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
10 #ifndef YARP_OS_OS_H
11 #define YARP_OS_OS_H
12 
13 #include <yarp/os/api.h>
14 
15 #include <cstddef>
16 
17 
18 namespace yarp {
19 namespace os {
20 
29 YARP_OS_API const char* getenv(const char* var);
30 
38 YARP_OS_API int getpid();
39 
40 #ifndef YARP_NO_DEPRECATED // Since YARP 3.0.0
41 
49 YARP_DEPRECATED
50 YARP_OS_API void setprogname(const char* progname);
51 
61 YARP_DEPRECATED_MSG("This method is deprecated. Use yarp::os::SystemInfo::getProcessInfo().name instead")
62 YARP_OS_API void getprogname(char* progname, size_t size);
63 #endif // YARP_NO_DEPRECATED
64 
74 YARP_OS_API void gethostname(char* hostname, size_t size);
75 
86 YARP_OS_API int mkdir(const char* p);
87 
98 YARP_OS_API int mkdir_p(const char* p, int ignoreLevels = 0);
99 
108 YARP_OS_API int rmdir(const char* p);
109 
120 YARP_OS_API int rename(const char* oldname, const char* newname);
121 
130 YARP_OS_API int stat(const char* path);
131 
146 YARP_OS_API char* getcwd(char* buf, size_t size);
147 
160 YARP_OS_API void setEnergySavingModeState(bool enabled);
161 
162 
163 #ifndef YARP_NO_DEPRECATED // Since YARP 2.3.70
164 enum
165 {
168 };
169 
170 typedef void (*YarpSignalHandler)(int);
180 YARP_DEPRECATED_MSG("Use std::signal")
181 YARP_OS_API YarpSignalHandler signal(int signum, YarpSignalHandler sighandler);
182 #endif // YARP_NO_DEPRECATED
183 
184 #ifndef YARP_NO_DEPRECATED // Since YARP 2.3.70
185 
190 YARP_OS_DEPRECATED_API_MSG("Use std::exit()")
191 void exit(int exit_code); // FIXME noreturn
192 #endif // YARP_NO_DEPRECATED
193 
194 #ifndef YARP_NO_DEPRECATED // Since YARP 2.3.70
195 
200 YARP_OS_DEPRECATED_API_MSG("Use std::abort()")
201 void abort(bool verbose = false);
202 #endif // YARP_NO_DEPRECATED
203 
204 #ifndef YARP_NO_DEPRECATED // Since YARP 3.0.0
205 
218 YARP_OS_DEPRECATED_API_MSG("Use native fork()")
219 int fork(void);
220 #endif // YARP_NO_DEPRECATED
221 
222 
223 } // namespace os
224 } // namespace yarp
225 
226 #endif // YARP_OS_OS_H
char * getcwd(char *buf, size_t size)
Portable wrapper for the getcwd() function.
Definition: Os.cpp:109
void setprogname(const char *progname)
Portable wrapper for the setprogname() function.
Definition: Os.cpp:72
The main, catch-all namespace for YARP.
const char * getenv(const char *var)
Portable wrapper for the getenv() function.
Definition: Os.cpp:34
int stat(const char *path)
Portable wrapper for the stat() function.
Definition: Os.cpp:59
void exit(int exit_code)
Portable wrapper for the exit() function.
Definition: Os.cpp:144
YarpSignalHandler signal(int signum, YarpSignalHandler sighandler)
Portable wrapper for the signal() function.
Definition: Os.cpp:130
bool verbose
Definition: yarpros.cpp:21
int rename(const char *oldname, const char *newname)
Portable wrapper for the rename() function.
Definition: Os.cpp:54
int getpid()
Portable wrapper for the getppid() function.
Definition: Os.cpp:65
void(* YarpSignalHandler)(int)
Definition: Os.h:170
void setEnergySavingModeState(bool enabled)
Toggle the OS energy saving feature.
Definition: Os.cpp:114
int fork(void)
Portable wrapper for the fork() function.
Definition: Os.cpp:167
void getprogname(char *progname, size_t size)
Portable wrapper for the getprogname() function.
Definition: Os.cpp:83
void gethostname(char *hostname, size_t size)
Portable wrapper for the gethostname() function.
Definition: Os.cpp:101
int rmdir(const char *p)
Portable wrapper for the rmdir() function.
Definition: Os.cpp:49
int mkdir(const char *p)
Portable wrapper for the mkdir() function.
Definition: Os.cpp:39
void abort(bool verbose=false)
Portable wrapper for the abort() function.
Definition: Os.cpp:151
int mkdir_p(const char *p, int ignoreLevels=0)
Create a directory and all parent directories needed.
Definition: Os.cpp:44