YARP
Yet Another Robot Platform
Os.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef YARP_OS_OS_H
8 #define YARP_OS_OS_H
9 
10 #include <yarp/os/api.h>
11 
12 #include <cstddef>
13 #include <string>
14 
15 
16 namespace yarp {
17 namespace os {
18 
19 #ifndef YARP_NO_DEPRECATED // Since YARP 3.4.0
30 YARP_DEPRECATED_MSG("Use std::getenv instead")
31 YARP_os_API const char* getenv(const char* var);
32 #endif // YARP_NO_DEPRECATED
33 
41 YARP_os_API int getpid();
42 
52 YARP_os_API void gethostname(char* hostname, size_t size);
53 
61 YARP_os_API std::string gethostname();
62 
73 YARP_os_API int mkdir(const char* p);
74 
85 YARP_os_API int mkdir_p(const char* p, int ignoreLevels = 0);
86 
95 YARP_os_API int rmdir(const char* p);
96 
107 YARP_os_API int rename(const char* oldname, const char* newname);
108 
117 YARP_os_API int stat(const char* path);
118 
131 YARP_os_API char* getcwd(char* buf, size_t size);
132 
144 YARP_os_API void setEnergySavingModeState(bool enabled);
145 
146 
147 #ifndef YARP_NO_DEPRECATED // Since YARP 3.0.0
156 YARP_DEPRECATED
157 YARP_os_API void setprogname(const char* progname);
158 
168 YARP_DEPRECATED_MSG("This method is deprecated. Use yarp::os::SystemInfo::getProcessInfo().name instead")
169 YARP_os_API void getprogname(char* progname, size_t size);
170 
183 YARP_os_DEPRECATED_API_MSG("Use native fork()")
184 int fork();
185 #endif // YARP_NO_DEPRECATED
186 
187 
188 } // namespace os
189 } // namespace yarp
190 
191 #endif // YARP_OS_OS_H
#define YARP_DEPRECATED_MSG(MSG)
Expands to either the standard [[deprecated]] attribute or a compiler-specific decorator such as __at...
Definition: compiler.h:2885
int mkdir(const char *p)
Portable wrapper for the mkdir() function.
Definition: Os.cpp:37
int rename(const char *oldname, const char *newname)
Portable wrapper for the rename() function.
Definition: Os.cpp:80
void setEnergySavingModeState(bool enabled)
Toggle the OS energy saving feature.
Definition: Os.cpp:117
char * getcwd(char *buf, size_t size)
Portable wrapper for the getcwd() function.
Definition: Os.cpp:112
int stat(const char *path)
Portable wrapper for the stat() function.
Definition: Os.cpp:85
int getpid()
Portable wrapper for the getppid() function.
Definition: Os.cpp:91
const char * getenv(const char *var)
Portable wrapper for the getenv() function.
Definition: Os.cpp:31
int fork()
Portable wrapper for the fork() function.
Definition: Os.cpp:159
int rmdir(const char *p)
Portable wrapper for the rmdir() function.
Definition: Os.cpp:75
void setprogname(const char *progname)
Portable wrapper for the setprogname() function.
Definition: Os.cpp:133
void gethostname(char *hostname, size_t size)
Portable wrapper for the gethostname() function.
Definition: Os.cpp:97
void getprogname(char *progname, size_t size)
Portable wrapper for the getprogname() function.
Definition: Os.cpp:143
int mkdir_p(const char *p, int ignoreLevels=0)
Create a directory and all parent directories needed.
Definition: Os.cpp:42
The main, catch-all namespace for YARP.
Definition: dirs.h:16
#define YARP_os_DEPRECATED_API_MSG(X)
Definition: api.h:21
#define YARP_os_API
Definition: api.h:18