DCL 3.7.4
Loading...
Searching...
No Matches
_unistd.cpp File Reference
#include <dcl/Config.h>
#include <errno.h>
#include <stdlib.h>
#include <limits.h>
#include <dcl/_unistd.h>
#include <dcl/Object.h>
#include <dcl/String.h>
#include "__strumbs.h"

Go to the source code of this file.

Functions

__DCL_BEGIN_NAMESPACE int __access (const String &_path, int _type)
int __chown (const String &_path, uid_t _owner, gid_t _group)
int __lchown (const String &_path, uid_t _owner, gid_t _group)
int __chdir (const String &_path)
int __getcwd (String &_r)
int __ttyname (int fd, String &_r)
int __link (const String &_from, const String &_to)
int __symlink (const String &_from, const String &_to)
ssize_t __readlink (const String &_path, String &_r)
int __unlink (const String &_path)
int __rmdir (const String &_path)
int __getlogin (String &_r)
int __gethostname (String &_r)
int __getdomainname (String _r)
int __truncate (const String &_path, off_t _len)

Function Documentation

◆ __access()

__DCL_BEGIN_NAMESPACE int __access ( const String & _path,
int _type )
Returns
== NULL or -1, see errno

Definition at line 25 of file _unistd.cpp.

26{
27 STRTOMBS_ER(_path, path);
28 return access(path, _type);
29}
#define STRTOMBS_ER(str, mbs)
Definition __strumbs.h:33

◆ __chdir()

int __chdir ( const String & _path)

Definition at line 43 of file _unistd.cpp.

44{
45 STRTOMBS_ER(_path, path);
46 return chdir(path);
47}

◆ __chown()

int __chown ( const String & _path,
uid_t _owner,
gid_t _group )

Definition at line 31 of file _unistd.cpp.

32{
33 STRTOMBS_ER(_path, path);
34 return chown(path, _owner, _group);
35}

◆ __getcwd()

int __getcwd ( String & _r)

Definition at line 49 of file _unistd.cpp.

50{
51 char buf[PATH_MAX + 1];
52 char* s = getcwd(buf, sizeof(buf));
53 if (s) {
54 MBSTOSTR_ER(s, (size_t)-1, _r);
55 return 0;
56 }
57 return -1;
58}
#define MBSTOSTR_ER(mbs, nmbs, str)
Definition __strumbs.h:19

◆ __getdomainname()

int __getdomainname ( String _r)

Definition at line 125 of file _unistd.cpp.

126{
127 char buf[PATH_MAX + 1];
128 int n = getdomainname(buf, sizeof(buf));
129 if (n == 0)
130 MBSTOSTR_ER(buf, (size_t)-1, _r);
131 return n;
132}

◆ __gethostname()

int __gethostname ( String & _r)

Definition at line 116 of file _unistd.cpp.

117{
118 char buf[PATH_MAX + 1];
119 int n = gethostname(buf, sizeof(buf));
120 if (n == 0)
121 MBSTOSTR_ER(buf, (size_t)-1, _r);
122 return n;
123}

◆ __getlogin()

int __getlogin ( String & _r)

Definition at line 107 of file _unistd.cpp.

108{
109 char buf[PATH_MAX + 1];
110 int n = getlogin_r(buf, sizeof(buf));
111 if (n == 0)
112 MBSTOSTR_ER(buf, (size_t)-1, _r);
113 return n;
114}

◆ __lchown()

int __lchown ( const String & _path,
uid_t _owner,
gid_t _group )

Definition at line 37 of file _unistd.cpp.

38{
39 STRTOMBS_ER(_path, path);
40 return lchown(path, _owner, _group);
41}

◆ __link()

int __link ( const String & _from,
const String & _to )

Definition at line 69 of file _unistd.cpp.

70{
71 STRTOMBS_ER(_from, from);
72 STRTOMBS_ER(_to, to);
73 return link(from, to);
74}

◆ __readlink()

ssize_t __readlink ( const String & _path,
String & _r )

Definition at line 83 of file _unistd.cpp.

84{
85 STRTOMBS_ER(_path, path);
86 char buf[PATH_MAX + 1];
87 ssize_t n = readlink(path, buf, sizeof(buf));
88 if (n != -1) {
89 MBSTOSTR_ER(buf, n, _r);
90 return _r.length();
91 }
92 return n;
93}

◆ __rmdir()

int __rmdir ( const String & _path)

Definition at line 101 of file _unistd.cpp.

102{
103 STRTOMBS_ER(_path, path);
104 return rmdir(path);
105}

◆ __symlink()

int __symlink ( const String & _from,
const String & _to )

Definition at line 76 of file _unistd.cpp.

77{
78 STRTOMBS_ER(_from, from);
79 STRTOMBS_ER(_to, to);
80 return symlink(from, to);
81}

◆ __truncate()

int __truncate ( const String & _path,
off_t _len )

Definition at line 134 of file _unistd.cpp.

135{
136 STRTOMBS_ER(_path, path);
137 return truncate(path, _len);
138}

◆ __ttyname()

int __ttyname ( int fd,
String & _r )

Definition at line 60 of file _unistd.cpp.

61{
62 char buf[PATH_MAX + 1];
63 int n = ttyname_r(fd, buf, sizeof(buf));
64 if (n == 0)
65 MBSTOSTR_ER(buf, (size_t)-1, _r);
66 return n;
67}

◆ __unlink()

int __unlink ( const String & _path)

Definition at line 95 of file _unistd.cpp.

96{
97 STRTOMBS_ER(_path, path);
98 return unlink(path);
99}