mirror of https://gitee.com/bigwinds/arangodb
fixed Windows compile errors
This commit is contained in:
parent
cf33a76f31
commit
8ec3d7b619
|
@ -488,11 +488,19 @@ bool TRI_ExistsFile (char const* path) {
|
|||
#endif
|
||||
|
||||
|
||||
size_t TRI_ChMod (char const* path, long mode, std::string &err) {
|
||||
if (chmod(path, mode) != 0) {
|
||||
int TRI_ChMod (char const* path, long mode, std::string& err) {
|
||||
int res;
|
||||
#ifdef _WIN32
|
||||
res = _chmod(path, static_cast<int>(mode));
|
||||
#else
|
||||
res = chmod(path, mode);
|
||||
#endif
|
||||
|
||||
if (res != 0) {
|
||||
err = "error setting desired mode " + std::to_string(mode) + " for file " + path + ": " + strerror(errno);
|
||||
return errno;
|
||||
}
|
||||
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ bool TRI_ExistsFile (char const* path);
|
|||
/// @brief sets the desired mode on a file, returns errno on error.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
size_t TRI_ChMod (char const* path, long mode, std::string &err);
|
||||
int TRI_ChMod (char const* path, long mode, std::string &err);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the last modification date of a file
|
||||
|
|
|
@ -1076,23 +1076,23 @@ static void JS_ChMod (const v8::FunctionCallbackInfo<v8::Value>& args) {
|
|||
}
|
||||
|
||||
long mode = 0;
|
||||
uint i;
|
||||
for (i = 0; i < modeStr.length(); i++) {
|
||||
if (!isdigit(modeStr[i])) {
|
||||
for (uint32_t i = 0; i < modeStr.length(); i++) {
|
||||
if (! isdigit(modeStr[i])) {
|
||||
TRI_V8_THROW_TYPE_ERROR("<mode> must be a string with up to 4 octal digits in it plus a leading zero.");
|
||||
}
|
||||
char buf[2];
|
||||
buf[0] = modeStr[i];
|
||||
buf[1] = '\0';
|
||||
uint8_t digit = (uint8_t)atoi(buf);
|
||||
uint8_t digit = (uint8_t) atoi(buf);
|
||||
if (digit >= 8) {
|
||||
TRI_V8_THROW_TYPE_ERROR("<mode> must be a string with up to 4 octal digits in it plus a leading zero.");
|
||||
}
|
||||
mode = mode | digit << ((modeStr.length() - i - 1) * 3);
|
||||
mode = mode | digit << ((modeStr.length() - i - 1) * 3);
|
||||
}
|
||||
string err;
|
||||
int rc = TRI_ChMod(*name, mode, err);
|
||||
if (rc != 0) {
|
||||
|
||||
if (rc != TRI_ERROR_NO_ERROR) {
|
||||
TRI_V8_THROW_EXCEPTION_MESSAGE(rc, err);
|
||||
}
|
||||
TRI_V8_RETURN_TRUE();
|
||||
|
|
Loading…
Reference in New Issue