DCL 4.0
Loading...
Searching...
No Matches
_unistd.cpp
Go to the documentation of this file.
1
2#include <dcl/Config.h>
3
4#if !__DCL_WINDOWS
5
6#include <errno.h> // errno
7#include <stdlib.h> // alloca
8#include <limits.h> // PATH_MAX
9#include <dcl/_unistd.h>
10#include <dcl/Object.h> // __T(str)
11#include <dcl/String.h>
12
13#include "__strumbs.h"
14
15#if __DCL_DEBUG
16#undef __THIS_FILE__
17const char_t __THIS_FILE__[] = __T("dcl/_unistd.cpp");
18#endif
19
20__DCL_BEGIN_NAMESPACE
21
22int __access(const String& _path, int _type)
23{
24 STRTOMBS_ER(_path, path);
25 return access(path, _type);
26}
27
28int __chown(const String& _path, uid_t _owner, gid_t _group)
29{
30 STRTOMBS_ER(_path, path);
31 return chown(path, _owner, _group);
32}
33
34int __lchown(const String& _path, uid_t _owner, gid_t _group)
35{
36 STRTOMBS_ER(_path, path);
37 return lchown(path, _owner, _group);
38}
39
40int __chdir(const String& _path)
41{
42 STRTOMBS_ER(_path, path);
43 return chdir(path);
44}
45
46int __getcwd(String& _r)
47{
48 char buf[PATH_MAX + 1];
49 char* s = getcwd(buf, sizeof(buf));
50 if (s) {
51 MBSTOSTR_ER(s, (size_t)-1, _r);
52 return 0;
53 }
54 return -1;
55}
56
57int __ttyname(int fd, String& _r)
58{
59 char buf[PATH_MAX + 1];
60 int n = ttyname_r(fd, buf, sizeof(buf));
61 if (n == 0)
62 MBSTOSTR_ER(buf, (size_t)-1, _r);
63 return n;
64}
65
66int __link(const String& _from, const String& _to)
67{
68 STRTOMBS_ER(_from, from);
69 STRTOMBS_ER(_to, to);
70 return link(from, to);
71}
72
73int __symlink(const String& _from, const String& _to)
74{
75 STRTOMBS_ER(_from, from);
76 STRTOMBS_ER(_to, to);
77 return symlink(from, to);
78}
79
80ssize_t __readlink(const String& _path, String& _r)
81{
82 STRTOMBS_ER(_path, path);
83 char buf[PATH_MAX + 1];
84 ssize_t n = readlink(path, buf, sizeof(buf));
85 if (n != -1) {
87 return _r.length();
88 }
89 return n;
90}
91
92int __unlink(const String& _path)
93{
94 STRTOMBS_ER(_path, path);
95 return unlink(path);
96}
97
98int __rmdir(const String& _path)
99{
100 STRTOMBS_ER(_path, path);
101 return rmdir(path);
102}
103
104int __getlogin(String& _r)
105{
106 char buf[PATH_MAX + 1];
107 int n = getlogin_r(buf, sizeof(buf));
108 if (n == 0)
109 MBSTOSTR_ER(buf, (size_t)-1, _r);
110 return n;
111}
112
113int __gethostname(String& _r)
114{
115 char buf[PATH_MAX + 1];
116 int n = gethostname(buf, sizeof(buf));
117 if (n == 0)
118 MBSTOSTR_ER(buf, (size_t)-1, _r);
119 return n;
120}
121
123{
124 char buf[PATH_MAX + 1];
125 int n = getdomainname(buf, sizeof(buf));
126 if (n == 0)
127 MBSTOSTR_ER(buf, (size_t)-1, _r);
128 return n;
129}
130
131int __truncate(const String& _path, off_t _len)
132{
133 STRTOMBS_ER(_path, path);
134 return truncate(path, _len);
135}
136
137__DCL_END_NAMESPACE
138
139#endif // !__DCL_WINDOWS
#define STRTOMBS_ER(str, mbs)
Definition __strumbs.h:33
#define MBSTOSTR_ER(mbs, nmbs, str)
Definition __strumbs.h:19
#define __THIS_FILE__
Definition _trace.h:14
int __symlink(const String &_from, const String &_to)
Definition _unistd.cpp:73
int __lchown(const String &_path, uid_t _owner, gid_t _group)
Definition _unistd.cpp:34
int __getlogin(String &_r)
Definition _unistd.cpp:104
int __chdir(const String &_path)
Definition _unistd.cpp:40
int __link(const String &_from, const String &_to)
Definition _unistd.cpp:66
int __gethostname(String &_r)
Definition _unistd.cpp:113
int __unlink(const String &_path)
Definition _unistd.cpp:92
int __getdomainname(String _r)
Definition _unistd.cpp:122
int __getcwd(String &_r)
Definition _unistd.cpp:46
int __rmdir(const String &_path)
Definition _unistd.cpp:98
ssize_t __readlink(const String &_path, String &_r)
Definition _unistd.cpp:80
int __truncate(const String &_path, off_t _len)
Definition _unistd.cpp:131
int __chown(const String &_path, uid_t _owner, gid_t _group)
Definition _unistd.cpp:28
__DCL_BEGIN_NAMESPACE int __access(const String &_path, int _type)
Definition _unistd.cpp:22
int __ttyname(int fd, String &_r)
Definition _unistd.cpp:57
wchar_t char_t
Definition Config.h:275
#define __T(str)
Definition Object.h:44
ByteBuffer * buf
_r
Definition SQLField.cpp:260
void CharsetConvertException *size_t n
Definition SQLField.cpp:253