53 m_h(INVALID_HANDLE_VALUE)
54 #ifndef WDL_NO_SUPPORT_UTF8
74 WDL_FastString scanstr(dirname);
75 const int l = scanstr.GetLength();
81 if (dirname[
l-1] ==
'\\' || dirname[
l-1] ==
'/') scanstr.SetLen(
l-1);
83 scanstr.Append(
"\\*");
92 while (idx > 0 &&
sp[idx] !=
'/' &&
sp[idx] !=
'\\') idx--;
96 if (dirname[
l-1] ==
'\\' || dirname[
l-1] ==
'/') scanstr.SetLen(
l-1);
98 if (!scanstr.GetLength()) scanstr.Set(
"/");
103 #ifndef WDL_NO_SUPPORT_UTF8
104 m_h=INVALID_HANDLE_VALUE;
105 #ifdef WDL_SUPPORT_WIN9X
106 m_wcmode = GetVersion()< 0x80000000;
113 int reqbuf = MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,scanstr.Get(),-1,
NULL,0);
118 if (MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,scanstr.Get(),-1,tmp.
Get(),tmp.
GetSize()-10))
120 correctlongpath(tmp.
Get());
121 m_h=FindFirstFileW(tmp.
Get(),&m_fd);
126 WCHAR wfilename[1024];
127 if (MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,scanstr.Get(),-1,wfilename,1024-10))
129 correctlongpath(wfilename);
130 m_h=FindFirstFileW(wfilename,&m_fd);
135 if (
m_h==INVALID_HANDLE_VALUE) m_wcmode=
false;
137 if (
m_h==INVALID_HANDLE_VALUE)
139 m_h=FindFirstFile(scanstr.Get(),(WIN32_FIND_DATA*)&m_fd);
140 return (
m_h == INVALID_HANDLE_VALUE);
143 m_h=opendir(scanstr.Get());
150 if (
m_h == INVALID_HANDLE_VALUE)
return -1;
151 #ifndef WDL_NO_SUPPORT_UTF8
152 if (m_wcmode)
return !FindNextFileW(
m_h,&m_fd);
154 return !FindNextFile(
m_h,(WIN32_FIND_DATA*)&m_fd);
163 if (
m_h != INVALID_HANDLE_VALUE) FindClose(
m_h);
164 m_h=INVALID_HANDLE_VALUE;
174#ifndef WDL_NO_SUPPORT_UTF8
177 if (!WideCharToMultiByte(CP_UTF8,0,m_fd.cFileName,-1,m_tmpbuf,
sizeof(m_tmpbuf),
NULL,
NULL))
182 return ((WIN32_FIND_DATA *)&m_fd)->cFileName;
200 return !!(m_fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
205 case DT_DIR:
return 1;
209 char *rp = realpath(tmp,
NULL);
213 int ret = (!stat(rp,&sb) && (sb.st_mode & S_IFMT) == S_IFDIR) ? 2 : 0;
217 const int rpl = (
int) strlen(rp);
233 DIR *
d = opendir(tmp);
244 DWORD GetCurrentFileSize(
DWORD *HighWord=
NULL)
const {
if (HighWord) *HighWord = m_fd.nFileSizeHigh;
return m_fd.nFileSizeLow; }
245 void GetCurrentLastWriteTime(FILETIME *ft)
const { *ft = m_fd.ftLastWriteTime; }
246 void GetCurrentLastAccessTime(FILETIME *ft)
const { *ft = m_fd.ftLastAccessTime; }
247 void GetCurrentCreationTime(FILETIME *ft)
const { *ft = m_fd.ftCreationTime; }
248 DWORD GetFileAttributes()
const {
return m_fd.dwFileAttributes; }
249#elif defined(_WDL_SWELL_H_)
251 void GetCurrentCreationTime(FILETIME *ft)
257 unsigned long long a=(
unsigned long long)st.st_ctime;
264 void GetCurrentLastWriteTime(FILETIME *ft)
270 unsigned long long a=(
unsigned long long)st.st_mtime;
283 if (HighWord) *HighWord = (
DWORD)(st.st_size>>32);
284 return (
DWORD)(st.st_size&0xffffffff);
292#ifndef WDL_NO_SUPPORT_UTF8
294 WIN32_FIND_DATAW m_fd;
297 WIN32_FIND_DATA m_fd;
307 static void correctlongpath(WCHAR *buf)
312 if (!buf || !buf[0] || wcslen(buf) < 256)
return;
313 if (buf[1] ==
':') insert=L
"\\\\?\\";
314 else if (buf[0] ==
'\\' && buf[1] ==
'\\') { insert = L
"\\\\?\\UNC\\"; skip=2; }
317 wr = buf + wcslen(insert);
318 memmove(wr, buf + skip, (wcslen(buf+skip)+1)*2);
319 memmove(buf,insert,wcslen(insert)*2);
322 if (*wr ==
'/') *wr =
'\\';