22 #define __MSVCRT_VERSION__ 0x601
26 #include <QtCore/QFile>
29 #include <sys/utime.h>
32 #define CONV(x) ((wchar_t*)x.utf16())
37 if (strlen(mode)<1 || strlen(mode)>3) {
42 strncpy(fixed_mode, mode, 3);
43 if (fixed_mode[0]==
'b' || fixed_mode[1]==
'b' || fixed_mode[0]==
't' || fixed_mode[1]==
't')
46 if (fixed_mode[1]==
'+') {
61 if ((flags & O_TEXT) == 0 && (flags & O_BINARY) == 0)
62 return flags | O_BINARY;
81 static const char letters[] =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
85 if ( !_template.endsWith(QLatin1String(
"XXXXXX")) )
88 strcpy(XXXXXX,
"XXXXXX");
89 const QString tmpl = _template.left(_template.length() - 6);
92 for (
int count = 0; count < 256; ++count)
97 XXXXXX[0] = letters[v % 62];
99 XXXXXX[1] = letters[v % 62];
101 XXXXXX[2] = letters[v % 62];
103 XXXXXX[3] = letters[v % 62];
105 XXXXXX[4] = letters[v % 62];
107 XXXXXX[5] = letters[v % 62];
114 const QString tmp = tmpl + QString::fromLatin1( XXXXXX );
127 if( ( mode & X_OK ) == X_OK ) {
131 if( ( st.st_mode & S_IXUSR ) != S_IXUSR )
135 return _waccess(
CONV(path), mode );
140 return _wchmod(
CONV(path), mode );
145 return _wfopen(
CONV(pathname),
CONV(QString::fromLatin1( mode )) );
155 return _wmkdir(
CONV(pathname) );
167 bool ok = ( MoveFileExW(
CONV(in),
CONV(out),
168 MOVEFILE_REPLACE_EXISTING|MOVEFILE_COPY_ALLOWED ) != 0 );
170 bool ok = ( MoveFileW(
CONV(in),
CONV(out)) != 0 );
187 const int len = path.length();
188 if ( (len==2 || len==3) && path[1]==QLatin1Char(
':') && path[0].isLetter() ) {
192 newPath += QLatin1Char(
'\\');
194 result = _wstat64(
CONV(newPath), &s64 );
196 result = wstat(
CONV(newPath), &st );
199 if ( len > 1 && (path.endsWith(QLatin1Char(
'\\')) || path.endsWith(QLatin1Char(
'/'))) ) {
201 const QString newPath = path.left( len - 1 );
203 result = _wstat64(
CONV(newPath), &s64 );
205 result = wstat(
CONV(newPath), &st );
210 result = _wstat64(
CONV(path), &s64 );
212 result = wstat(
CONV(path), &st );
219 buf->st_dev = s64.st_dev;
220 buf->st_ino = s64.st_ino;
221 buf->st_mode = s64.st_mode;
222 buf->st_nlink = s64.st_nlink;
224 buf->st_dev = st.st_dev;
225 buf->st_ino = st.st_ino;
226 buf->st_mode = st.st_mode;
227 buf->st_nlink = st.st_nlink;
232 buf->st_rdev = s64.st_rdev;
233 buf->st_size = s64.st_size;
234 buf->st_atime = s64.st_atime;
235 buf->st_mtime = s64.st_mtime;
236 buf->st_ctime = s64.st_ctime;
238 buf->st_rdev = st.st_rdev;
239 buf->st_size = st.st_size;
240 buf->st_atime = st.st_atime;
241 buf->st_mtime = st.st_mtime;
242 buf->st_ctime = st.st_ctime;
249 return _wutime(
CONV(filename), (
struct _utimbuf*)buf );
251 return _wutime(
CONV(filename), (
struct utimbuf*)buf );
static int kdewin_fix_mode_string(char *fixed_mode, const char *mode)
int mkdir(const QString &pathname, mode_t)
int stat(const QString &path, KDE_struct_stat *buf)
int rename(const QString &in, const QString &out)
int chmod(const QString &path, mode_t mode)
QString mkdtemp_QString(const QString &_template)
int open(const QString &pathname, int flags, mode_t mode)
static int kdewin_fix_flags(int flags)
int lstat(const QString &path, KDE_struct_stat *buf)
int access(const QString &path, int mode)
FILE * fopen(const QString &pathname, const char *mode)
int utime(const QString &filename, struct utimbuf *buf)