|
|
@@ -246441,120 +246441,133 @@ private: |
|
|
if (sessionHandle != 0) |
|
|
if (sessionHandle != 0) |
|
|
{ |
|
|
{ |
|
|
// break up the url.. |
|
|
// break up the url.. |
|
|
TCHAR file[1024], server[1024], username[1024], password[1024]; |
|
|
|
|
|
|
|
|
const int fileNumChars = 65536; |
|
|
|
|
|
const int serverNumChars = 2048; |
|
|
|
|
|
const int usernameNumChars = 1024; |
|
|
|
|
|
const int passwordNumChars = 1024; |
|
|
|
|
|
HeapBlock<TCHAR> file (fileNumChars), server (serverNumChars), |
|
|
|
|
|
username (usernameNumChars), password (passwordNumChars); |
|
|
|
|
|
|
|
|
URL_COMPONENTS uc = { 0 }; |
|
|
URL_COMPONENTS uc = { 0 }; |
|
|
uc.dwStructSize = sizeof (uc); |
|
|
uc.dwStructSize = sizeof (uc); |
|
|
uc.lpszUrlPath = file; |
|
|
uc.lpszUrlPath = file; |
|
|
uc.dwUrlPathLength = numElementsInArray (file); |
|
|
|
|
|
|
|
|
uc.dwUrlPathLength = fileNumChars; |
|
|
uc.lpszHostName = server; |
|
|
uc.lpszHostName = server; |
|
|
uc.dwHostNameLength = numElementsInArray (server); |
|
|
|
|
|
|
|
|
uc.dwHostNameLength = serverNumChars; |
|
|
uc.lpszUserName = username; |
|
|
uc.lpszUserName = username; |
|
|
uc.dwUserNameLength = numElementsInArray (username); |
|
|
|
|
|
|
|
|
uc.dwUserNameLength = usernameNumChars; |
|
|
uc.lpszPassword = password; |
|
|
uc.lpszPassword = password; |
|
|
uc.dwPasswordLength = numElementsInArray (password); |
|
|
|
|
|
|
|
|
uc.dwPasswordLength = passwordNumChars; |
|
|
|
|
|
|
|
|
if (InternetCrackUrl (address.toWideCharPointer(), 0, 0, &uc)) |
|
|
if (InternetCrackUrl (address.toWideCharPointer(), 0, 0, &uc)) |
|
|
{ |
|
|
|
|
|
int disable = 1; |
|
|
|
|
|
InternetSetOption (sessionHandle, INTERNET_OPTION_DISABLE_AUTODIAL, &disable, sizeof (disable)); |
|
|
|
|
|
|
|
|
openConnection (uc, sessionHandle, progressCallback, progressCallbackContext); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (timeOutMs == 0) |
|
|
|
|
|
timeOutMs = 30000; |
|
|
|
|
|
else if (timeOutMs < 0) |
|
|
|
|
|
timeOutMs = -1; |
|
|
|
|
|
|
|
|
void openConnection (URL_COMPONENTS& uc, HINTERNET sessionHandle, |
|
|
|
|
|
URL::OpenStreamProgressCallback* progressCallback, |
|
|
|
|
|
void* progressCallbackContext) |
|
|
|
|
|
{ |
|
|
|
|
|
int disable = 1; |
|
|
|
|
|
InternetSetOption (sessionHandle, INTERNET_OPTION_DISABLE_AUTODIAL, &disable, sizeof (disable)); |
|
|
|
|
|
|
|
|
InternetSetOption (sessionHandle, INTERNET_OPTION_CONNECT_TIMEOUT, &timeOutMs, sizeof (timeOutMs)); |
|
|
|
|
|
|
|
|
if (timeOutMs == 0) |
|
|
|
|
|
timeOutMs = 30000; |
|
|
|
|
|
else if (timeOutMs < 0) |
|
|
|
|
|
timeOutMs = -1; |
|
|
|
|
|
|
|
|
const bool isFtp = address.startsWithIgnoreCase ("ftp:"); |
|
|
|
|
|
|
|
|
InternetSetOption (sessionHandle, INTERNET_OPTION_CONNECT_TIMEOUT, &timeOutMs, sizeof (timeOutMs)); |
|
|
|
|
|
|
|
|
#if WORKAROUND_TIMEOUT_BUG |
|
|
|
|
|
connection = 0; |
|
|
|
|
|
|
|
|
const bool isFtp = address.startsWithIgnoreCase ("ftp:"); |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
InternetConnectThread connectThread (uc, sessionHandle, connection, isFtp); |
|
|
|
|
|
connectThread.wait (timeOutMs); |
|
|
|
|
|
|
|
|
#if WORKAROUND_TIMEOUT_BUG |
|
|
|
|
|
connection = 0; |
|
|
|
|
|
|
|
|
if (connection == 0) |
|
|
|
|
|
{ |
|
|
|
|
|
InternetCloseHandle (sessionHandle); |
|
|
|
|
|
sessionHandle = 0; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
#else |
|
|
|
|
|
connection = InternetConnect (sessionHandle, uc.lpszHostName, uc.nPort, |
|
|
|
|
|
uc.lpszUserName, uc.lpszPassword, |
|
|
|
|
|
isFtp ? INTERNET_SERVICE_FTP |
|
|
|
|
|
: INTERNET_SERVICE_HTTP, |
|
|
|
|
|
0, 0); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
if (connection != 0) |
|
|
|
|
|
{ |
|
|
|
|
|
if (isFtp) |
|
|
|
|
|
{ |
|
|
|
|
|
request = FtpOpenFile (connection, uc.lpszUrlPath, GENERIC_READ, |
|
|
|
|
|
FTP_TRANSFER_TYPE_BINARY | INTERNET_FLAG_NEED_FILE, 0); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
const TCHAR* mimeTypes[] = { _T("*/*"), 0 }; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
InternetConnectThread connectThread (uc, sessionHandle, connection, isFtp); |
|
|
|
|
|
connectThread.wait (timeOutMs); |
|
|
|
|
|
|
|
|
DWORD flags = INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_NO_COOKIES; |
|
|
|
|
|
|
|
|
if (connection == 0) |
|
|
|
|
|
{ |
|
|
|
|
|
InternetCloseHandle (sessionHandle); |
|
|
|
|
|
sessionHandle = 0; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
#else |
|
|
|
|
|
connection = InternetConnect (sessionHandle, uc.lpszHostName, uc.nPort, |
|
|
|
|
|
uc.lpszUserName, uc.lpszPassword, |
|
|
|
|
|
isFtp ? INTERNET_SERVICE_FTP |
|
|
|
|
|
: INTERNET_SERVICE_HTTP, |
|
|
|
|
|
0, 0); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
if (address.startsWithIgnoreCase ("https:")) |
|
|
|
|
|
flags |= INTERNET_FLAG_SECURE; // (this flag only seems necessary if the OS is running IE6 - |
|
|
|
|
|
// IE7 seems to automatically work out when it's https) |
|
|
|
|
|
|
|
|
if (connection != 0) |
|
|
|
|
|
{ |
|
|
|
|
|
if (isFtp) |
|
|
|
|
|
request = FtpOpenFile (connection, uc.lpszUrlPath, GENERIC_READ, |
|
|
|
|
|
FTP_TRANSFER_TYPE_BINARY | INTERNET_FLAG_NEED_FILE, 0); |
|
|
|
|
|
else |
|
|
|
|
|
openHTTPConnection (uc, sessionHandle, progressCallback, progressCallbackContext); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
request = HttpOpenRequest (connection, isPost ? _T("POST") : _T("GET"), |
|
|
|
|
|
uc.lpszUrlPath, 0, 0, mimeTypes, flags, 0); |
|
|
|
|
|
|
|
|
void openHTTPConnection (URL_COMPONENTS& uc, HINTERNET sessionHandle, |
|
|
|
|
|
URL::OpenStreamProgressCallback* progressCallback, |
|
|
|
|
|
void* progressCallbackContext) |
|
|
|
|
|
{ |
|
|
|
|
|
const TCHAR* mimeTypes[] = { _T("*/*"), 0 }; |
|
|
|
|
|
|
|
|
if (request != 0) |
|
|
|
|
|
{ |
|
|
|
|
|
INTERNET_BUFFERS buffers = { 0 }; |
|
|
|
|
|
buffers.dwStructSize = sizeof (INTERNET_BUFFERS); |
|
|
|
|
|
buffers.lpcszHeader = headers.toWideCharPointer(); |
|
|
|
|
|
buffers.dwHeadersLength = headers.length(); |
|
|
|
|
|
buffers.dwBufferTotal = (DWORD) postData.getSize(); |
|
|
|
|
|
|
|
|
DWORD flags = INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_NO_COOKIES; |
|
|
|
|
|
|
|
|
if (HttpSendRequestEx (request, &buffers, 0, HSR_INITIATE, 0)) |
|
|
|
|
|
{ |
|
|
|
|
|
int bytesSent = 0; |
|
|
|
|
|
|
|
|
if (address.startsWithIgnoreCase ("https:")) |
|
|
|
|
|
flags |= INTERNET_FLAG_SECURE; // (this flag only seems necessary if the OS is running IE6 - |
|
|
|
|
|
// IE7 seems to automatically work out when it's https) |
|
|
|
|
|
|
|
|
for (;;) |
|
|
|
|
|
{ |
|
|
|
|
|
const int bytesToDo = jmin (1024, (int) postData.getSize() - bytesSent); |
|
|
|
|
|
DWORD bytesDone = 0; |
|
|
|
|
|
|
|
|
request = HttpOpenRequest (connection, isPost ? _T("POST") : _T("GET"), |
|
|
|
|
|
uc.lpszUrlPath, 0, 0, mimeTypes, flags, 0); |
|
|
|
|
|
|
|
|
if (bytesToDo > 0 |
|
|
|
|
|
&& ! InternetWriteFile (request, |
|
|
|
|
|
static_cast <const char*> (postData.getData()) + bytesSent, |
|
|
|
|
|
bytesToDo, &bytesDone)) |
|
|
|
|
|
{ |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (request != 0) |
|
|
|
|
|
{ |
|
|
|
|
|
INTERNET_BUFFERS buffers = { 0 }; |
|
|
|
|
|
buffers.dwStructSize = sizeof (INTERNET_BUFFERS); |
|
|
|
|
|
buffers.lpcszHeader = headers.toWideCharPointer(); |
|
|
|
|
|
buffers.dwHeadersLength = headers.length(); |
|
|
|
|
|
buffers.dwBufferTotal = (DWORD) postData.getSize(); |
|
|
|
|
|
|
|
|
if (bytesToDo == 0 || (int) bytesDone < bytesToDo) |
|
|
|
|
|
{ |
|
|
|
|
|
if (HttpEndRequest (request, 0, 0, 0)) |
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
if (HttpSendRequestEx (request, &buffers, 0, HSR_INITIATE, 0)) |
|
|
|
|
|
{ |
|
|
|
|
|
int bytesSent = 0; |
|
|
|
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
for (;;) |
|
|
|
|
|
{ |
|
|
|
|
|
const int bytesToDo = jmin (1024, (int) postData.getSize() - bytesSent); |
|
|
|
|
|
DWORD bytesDone = 0; |
|
|
|
|
|
|
|
|
bytesSent += bytesDone; |
|
|
|
|
|
|
|
|
if (bytesToDo > 0 |
|
|
|
|
|
&& ! InternetWriteFile (request, |
|
|
|
|
|
static_cast <const char*> (postData.getData()) + bytesSent, |
|
|
|
|
|
bytesToDo, &bytesDone)) |
|
|
|
|
|
{ |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (progressCallback != nullptr && ! progressCallback (progressCallbackContext, bytesSent, postData.getSize())) |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (bytesToDo == 0 || (int) bytesDone < bytesToDo) |
|
|
|
|
|
{ |
|
|
|
|
|
if (HttpEndRequest (request, 0, 0, 0)) |
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
close(); |
|
|
|
|
|
|
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bytesSent += bytesDone; |
|
|
|
|
|
|
|
|
|
|
|
if (progressCallback != nullptr && ! progressCallback (progressCallbackContext, bytesSent, postData.getSize())) |
|
|
|
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
close(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WebInputStream); |
|
|
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WebInputStream); |
|
|
@@ -262114,20 +262127,18 @@ bool File::setAsCurrentWorkingDirectory() const |
|
|
|
|
|
|
|
|
namespace |
|
|
namespace |
|
|
{ |
|
|
{ |
|
|
#if JUCE_IOS && ! __DARWIN_ONLY_64_BIT_INO_T |
|
|
|
|
|
typedef struct stat64 juce_statStruct; // (need to use the 64-bit version to work around a simulator bug) |
|
|
|
|
|
#else |
|
|
|
|
|
typedef struct stat juce_statStruct; |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
#if JUCE_LINUX || (JUCE_IOS && ! __DARWIN_ONLY_64_BIT_INO_T) // (this iOS stuff is to avoid a simulator bug) |
|
|
|
|
|
typedef struct stat64 juce_statStruct; |
|
|
|
|
|
#define JUCE_STAT stat64 |
|
|
|
|
|
#else |
|
|
|
|
|
typedef struct stat juce_statStruct; |
|
|
|
|
|
#define JUCE_STAT stat |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
bool juce_stat (const String& fileName, juce_statStruct& info) |
|
|
bool juce_stat (const String& fileName, juce_statStruct& info) |
|
|
{ |
|
|
{ |
|
|
return fileName.isNotEmpty() |
|
|
return fileName.isNotEmpty() |
|
|
#if JUCE_IOS && ! __DARWIN_ONLY_64_BIT_INO_T |
|
|
|
|
|
&& (stat64 (fileName.toUTF8(), &info) == 0); |
|
|
|
|
|
#else |
|
|
|
|
|
&& (stat (fileName.toUTF8(), &info) == 0); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
&& JUCE_STAT (fileName.toUTF8(), &info) == 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// if this file doesn't exist, find a parent of it that does.. |
|
|
// if this file doesn't exist, find a parent of it that does.. |
|
|
@@ -262147,14 +262158,14 @@ namespace |
|
|
void updateStatInfoForFile (const String& path, bool* const isDir, int64* const fileSize, |
|
|
void updateStatInfoForFile (const String& path, bool* const isDir, int64* const fileSize, |
|
|
Time* const modTime, Time* const creationTime, bool* const isReadOnly) |
|
|
Time* const modTime, Time* const creationTime, bool* const isReadOnly) |
|
|
{ |
|
|
{ |
|
|
if (isDir != 0 || fileSize != 0 || modTime != 0 || creationTime != 0) |
|
|
|
|
|
|
|
|
if (isDir != nullptr || fileSize != nullptr || modTime != nullptr || creationTime != nullptr) |
|
|
{ |
|
|
{ |
|
|
juce_statStruct info; |
|
|
juce_statStruct info; |
|
|
const bool statOk = juce_stat (path, info); |
|
|
const bool statOk = juce_stat (path, info); |
|
|
|
|
|
|
|
|
if (isDir != nullptr) *isDir = statOk && ((info.st_mode & S_IFDIR) != 0); |
|
|
|
|
|
if (fileSize != nullptr) *fileSize = statOk ? info.st_size : 0; |
|
|
|
|
|
if (modTime != nullptr) *modTime = Time (statOk ? (int64) info.st_mtime * 1000 : 0); |
|
|
|
|
|
|
|
|
if (isDir != nullptr) *isDir = statOk && ((info.st_mode & S_IFDIR) != 0); |
|
|
|
|
|
if (fileSize != nullptr) *fileSize = statOk ? info.st_size : 0; |
|
|
|
|
|
if (modTime != nullptr) *modTime = Time (statOk ? (int64) info.st_mtime * 1000 : 0); |
|
|
if (creationTime != nullptr) *creationTime = Time (statOk ? (int64) info.st_ctime * 1000 : 0); |
|
|
if (creationTime != nullptr) *creationTime = Time (statOk ? (int64) info.st_ctime * 1000 : 0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@@ -262183,14 +262194,8 @@ bool File::isDirectory() const |
|
|
|
|
|
|
|
|
bool File::exists() const |
|
|
bool File::exists() const |
|
|
{ |
|
|
{ |
|
|
juce_statStruct info; |
|
|
|
|
|
|
|
|
|
|
|
return fullPath.isNotEmpty() |
|
|
return fullPath.isNotEmpty() |
|
|
#if JUCE_IOS && ! __DARWIN_ONLY_64_BIT_INO_T |
|
|
|
|
|
&& (lstat64 (fullPath.toUTF8(), &info) == 0); |
|
|
|
|
|
#else |
|
|
|
|
|
&& (lstat (fullPath.toUTF8(), &info) == 0); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
&& access (fullPath.toUTF8(), F_OK) == 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool File::existsAsFile() const |
|
|
bool File::existsAsFile() const |
|
|
@@ -272056,20 +272061,18 @@ bool File::setAsCurrentWorkingDirectory() const |
|
|
|
|
|
|
|
|
namespace |
|
|
namespace |
|
|
{ |
|
|
{ |
|
|
#if JUCE_IOS && ! __DARWIN_ONLY_64_BIT_INO_T |
|
|
|
|
|
typedef struct stat64 juce_statStruct; // (need to use the 64-bit version to work around a simulator bug) |
|
|
|
|
|
#else |
|
|
|
|
|
typedef struct stat juce_statStruct; |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
#if JUCE_LINUX || (JUCE_IOS && ! __DARWIN_ONLY_64_BIT_INO_T) // (this iOS stuff is to avoid a simulator bug) |
|
|
|
|
|
typedef struct stat64 juce_statStruct; |
|
|
|
|
|
#define JUCE_STAT stat64 |
|
|
|
|
|
#else |
|
|
|
|
|
typedef struct stat juce_statStruct; |
|
|
|
|
|
#define JUCE_STAT stat |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
bool juce_stat (const String& fileName, juce_statStruct& info) |
|
|
bool juce_stat (const String& fileName, juce_statStruct& info) |
|
|
{ |
|
|
{ |
|
|
return fileName.isNotEmpty() |
|
|
return fileName.isNotEmpty() |
|
|
#if JUCE_IOS && ! __DARWIN_ONLY_64_BIT_INO_T |
|
|
|
|
|
&& (stat64 (fileName.toUTF8(), &info) == 0); |
|
|
|
|
|
#else |
|
|
|
|
|
&& (stat (fileName.toUTF8(), &info) == 0); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
&& JUCE_STAT (fileName.toUTF8(), &info) == 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// if this file doesn't exist, find a parent of it that does.. |
|
|
// if this file doesn't exist, find a parent of it that does.. |
|
|
@@ -272089,14 +272092,14 @@ namespace |
|
|
void updateStatInfoForFile (const String& path, bool* const isDir, int64* const fileSize, |
|
|
void updateStatInfoForFile (const String& path, bool* const isDir, int64* const fileSize, |
|
|
Time* const modTime, Time* const creationTime, bool* const isReadOnly) |
|
|
Time* const modTime, Time* const creationTime, bool* const isReadOnly) |
|
|
{ |
|
|
{ |
|
|
if (isDir != 0 || fileSize != 0 || modTime != 0 || creationTime != 0) |
|
|
|
|
|
|
|
|
if (isDir != nullptr || fileSize != nullptr || modTime != nullptr || creationTime != nullptr) |
|
|
{ |
|
|
{ |
|
|
juce_statStruct info; |
|
|
juce_statStruct info; |
|
|
const bool statOk = juce_stat (path, info); |
|
|
const bool statOk = juce_stat (path, info); |
|
|
|
|
|
|
|
|
if (isDir != nullptr) *isDir = statOk && ((info.st_mode & S_IFDIR) != 0); |
|
|
|
|
|
if (fileSize != nullptr) *fileSize = statOk ? info.st_size : 0; |
|
|
|
|
|
if (modTime != nullptr) *modTime = Time (statOk ? (int64) info.st_mtime * 1000 : 0); |
|
|
|
|
|
|
|
|
if (isDir != nullptr) *isDir = statOk && ((info.st_mode & S_IFDIR) != 0); |
|
|
|
|
|
if (fileSize != nullptr) *fileSize = statOk ? info.st_size : 0; |
|
|
|
|
|
if (modTime != nullptr) *modTime = Time (statOk ? (int64) info.st_mtime * 1000 : 0); |
|
|
if (creationTime != nullptr) *creationTime = Time (statOk ? (int64) info.st_ctime * 1000 : 0); |
|
|
if (creationTime != nullptr) *creationTime = Time (statOk ? (int64) info.st_ctime * 1000 : 0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@@ -272125,14 +272128,8 @@ bool File::isDirectory() const |
|
|
|
|
|
|
|
|
bool File::exists() const |
|
|
bool File::exists() const |
|
|
{ |
|
|
{ |
|
|
juce_statStruct info; |
|
|
|
|
|
|
|
|
|
|
|
return fullPath.isNotEmpty() |
|
|
return fullPath.isNotEmpty() |
|
|
#if JUCE_IOS && ! __DARWIN_ONLY_64_BIT_INO_T |
|
|
|
|
|
&& (lstat64 (fullPath.toUTF8(), &info) == 0); |
|
|
|
|
|
#else |
|
|
|
|
|
&& (lstat (fullPath.toUTF8(), &info) == 0); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
&& access (fullPath.toUTF8(), F_OK) == 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool File::existsAsFile() const |
|
|
bool File::existsAsFile() const |
|
|
@@ -289063,20 +289060,18 @@ bool File::setAsCurrentWorkingDirectory() const |
|
|
|
|
|
|
|
|
namespace |
|
|
namespace |
|
|
{ |
|
|
{ |
|
|
#if JUCE_IOS && ! __DARWIN_ONLY_64_BIT_INO_T |
|
|
|
|
|
typedef struct stat64 juce_statStruct; // (need to use the 64-bit version to work around a simulator bug) |
|
|
|
|
|
#else |
|
|
|
|
|
typedef struct stat juce_statStruct; |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
#if JUCE_LINUX || (JUCE_IOS && ! __DARWIN_ONLY_64_BIT_INO_T) // (this iOS stuff is to avoid a simulator bug) |
|
|
|
|
|
typedef struct stat64 juce_statStruct; |
|
|
|
|
|
#define JUCE_STAT stat64 |
|
|
|
|
|
#else |
|
|
|
|
|
typedef struct stat juce_statStruct; |
|
|
|
|
|
#define JUCE_STAT stat |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
bool juce_stat (const String& fileName, juce_statStruct& info) |
|
|
bool juce_stat (const String& fileName, juce_statStruct& info) |
|
|
{ |
|
|
{ |
|
|
return fileName.isNotEmpty() |
|
|
return fileName.isNotEmpty() |
|
|
#if JUCE_IOS && ! __DARWIN_ONLY_64_BIT_INO_T |
|
|
|
|
|
&& (stat64 (fileName.toUTF8(), &info) == 0); |
|
|
|
|
|
#else |
|
|
|
|
|
&& (stat (fileName.toUTF8(), &info) == 0); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
&& JUCE_STAT (fileName.toUTF8(), &info) == 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// if this file doesn't exist, find a parent of it that does.. |
|
|
// if this file doesn't exist, find a parent of it that does.. |
|
|
@@ -289096,14 +289091,14 @@ namespace |
|
|
void updateStatInfoForFile (const String& path, bool* const isDir, int64* const fileSize, |
|
|
void updateStatInfoForFile (const String& path, bool* const isDir, int64* const fileSize, |
|
|
Time* const modTime, Time* const creationTime, bool* const isReadOnly) |
|
|
Time* const modTime, Time* const creationTime, bool* const isReadOnly) |
|
|
{ |
|
|
{ |
|
|
if (isDir != 0 || fileSize != 0 || modTime != 0 || creationTime != 0) |
|
|
|
|
|
|
|
|
if (isDir != nullptr || fileSize != nullptr || modTime != nullptr || creationTime != nullptr) |
|
|
{ |
|
|
{ |
|
|
juce_statStruct info; |
|
|
juce_statStruct info; |
|
|
const bool statOk = juce_stat (path, info); |
|
|
const bool statOk = juce_stat (path, info); |
|
|
|
|
|
|
|
|
if (isDir != nullptr) *isDir = statOk && ((info.st_mode & S_IFDIR) != 0); |
|
|
|
|
|
if (fileSize != nullptr) *fileSize = statOk ? info.st_size : 0; |
|
|
|
|
|
if (modTime != nullptr) *modTime = Time (statOk ? (int64) info.st_mtime * 1000 : 0); |
|
|
|
|
|
|
|
|
if (isDir != nullptr) *isDir = statOk && ((info.st_mode & S_IFDIR) != 0); |
|
|
|
|
|
if (fileSize != nullptr) *fileSize = statOk ? info.st_size : 0; |
|
|
|
|
|
if (modTime != nullptr) *modTime = Time (statOk ? (int64) info.st_mtime * 1000 : 0); |
|
|
if (creationTime != nullptr) *creationTime = Time (statOk ? (int64) info.st_ctime * 1000 : 0); |
|
|
if (creationTime != nullptr) *creationTime = Time (statOk ? (int64) info.st_ctime * 1000 : 0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@@ -289132,14 +289127,8 @@ bool File::isDirectory() const |
|
|
|
|
|
|
|
|
bool File::exists() const |
|
|
bool File::exists() const |
|
|
{ |
|
|
{ |
|
|
juce_statStruct info; |
|
|
|
|
|
|
|
|
|
|
|
return fullPath.isNotEmpty() |
|
|
return fullPath.isNotEmpty() |
|
|
#if JUCE_IOS && ! __DARWIN_ONLY_64_BIT_INO_T |
|
|
|
|
|
&& (lstat64 (fullPath.toUTF8(), &info) == 0); |
|
|
|
|
|
#else |
|
|
|
|
|
&& (lstat (fullPath.toUTF8(), &info) == 0); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
&& access (fullPath.toUTF8(), F_OK) == 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool File::existsAsFile() const |
|
|
bool File::existsAsFile() const |
|
|
|