26 |
#include "lscpevent.h" |
#include "lscpevent.h" |
27 |
|
|
28 |
#if defined(WIN32) |
#if defined(WIN32) |
29 |
|
#include <windows.h> |
30 |
#else |
#else |
31 |
#include <fcntl.h> |
#include <fcntl.h> |
32 |
#endif |
#endif |
2518 |
} |
} |
2519 |
|
|
2520 |
void LSCPServer::VerifyFile(String Filename) { |
void LSCPServer::VerifyFile(String Filename) { |
2521 |
|
#if WIN32 |
2522 |
|
WIN32_FIND_DATA win32FileAttributeData; |
2523 |
|
BOOL res = GetFileAttributesEx( Filename.c_str(), GetFileExInfoStandard, &win32FileAttributeData ); |
2524 |
|
if (!res) { |
2525 |
|
std::stringstream ss; |
2526 |
|
ss << "File does not exist, GetFileAttributesEx failed `" << Filename << "`: Error " << GetLastError(); |
2527 |
|
throw Exception(ss.str()); |
2528 |
|
} |
2529 |
|
if ( win32FileAttributeData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) { |
2530 |
|
throw Exception("Directory is specified"); |
2531 |
|
} |
2532 |
|
#else |
2533 |
struct stat statBuf; |
struct stat statBuf; |
2534 |
int res = stat(Filename.c_str(), &statBuf); |
int res = stat(Filename.c_str(), &statBuf); |
2535 |
if (res) { |
if (res) { |
2541 |
if (S_ISDIR(statBuf.st_mode)) { |
if (S_ISDIR(statBuf.st_mode)) { |
2542 |
throw Exception("Directory is specified"); |
throw Exception("Directory is specified"); |
2543 |
} |
} |
2544 |
|
#endif |
2545 |
} |
} |
2546 |
|
|
2547 |
/** |
/** |