122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
-
-
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
|
#if !defined(HAVE_READDIR_R) && !defined(_WIN32) && defined(OF_HAVE_THREADS)
static of_mutex_t mutex;
#endif
int
of_stat(OFString *path, of_stat_t *buffer)
{
#ifdef _WIN32
return _wstat([path UTF16String], buffer);
#if defined(_WIN32)
return _wstat64([path UTF16String], buffer);
#elif defined(OF_HAVE_OFF64_T)
return stat64([path cStringWithEncoding:
[OFSystemInfo native8BitEncoding]], buffer);
#else
return stat([path cStringWithEncoding:
[OFSystemInfo native8BitEncoding]], buffer);
#endif
}
int
of_lstat(OFString *path, of_stat_t *buffer)
{
#if defined(_WIN32)
return _wstat([path UTF16String], buffer);
return _wstat64([path UTF16String], buffer);
#elif defined(HAVE_LSTAT)
# ifdef OF_HAVE_OFF64_T
return lstat64([path cStringWithEncoding:
[OFSystemInfo native8BitEncoding]], buffer);
# else
return lstat([path cStringWithEncoding:
[OFSystemInfo native8BitEncoding]], buffer);
# endif
#else
# ifdef OF_HAVE_OFF64_T
return stat64([path cStringWithEncoding:
[OFSystemInfo native8BitEncoding]], buffer);
# else
return stat([path cStringWithEncoding:
[OFSystemInfo native8BitEncoding]], buffer);
# endif
#endif
}
static int
parseMode(const char *mode)
{
if (strcmp(mode, "r") == 0)
|
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
|
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
|
-
-
+
+
+
+
+
-
-
+
+
|
int flags;
if ((flags = parseMode([mode UTF8String])) == -1)
@throw [OFInvalidArgumentException exception];
flags |= O_CLOEXEC;
#ifndef _WIN32
if ((_fd = open([path cStringWithEncoding: [OFSystemInfo
#if defined(_WIN32)
if ((_fd = _wopen([path UTF16String], flags,
DEFAULT_MODE)) == -1)
#elif defined(OF_HAVE_OFF64_T)
if ((_fd = open64([path cStringWithEncoding: [OFSystemInfo
native8BitEncoding]], flags, DEFAULT_MODE)) == -1)
#else
if ((_fd = _wopen([path UTF16String], flags,
DEFAULT_MODE)) == -1)
if ((_fd = open([path cStringWithEncoding: [OFSystemInfo
native8BitEncoding]], flags, DEFAULT_MODE)) == -1)
#endif
@throw [OFOpenFileFailedException
exceptionWithPath: path
mode: mode];
} @catch (id e) {
[self release];
@throw e;
|
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
|
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
|
+
+
+
+
+
+
|
requestedLength: length];
#endif
}
- (of_offset_t)lowlevelSeekToOffset: (of_offset_t)offset
whence: (int)whence
{
#if defined(_WIN32)
of_offset_t ret = _lseeki64(_fd, offset, whence);
#elif defined(OF_HAVE_OFF64_T)
of_offset_t ret = lseek64(_fd, offset, whence);
#else
of_offset_t ret = lseek(_fd, offset, whence);
#endif
if (ret == -1)
@throw [OFSeekFailedException exceptionWithStream: self
offset: offset
whence: whence];
_atEndOfStream = false;
|