//
-// Open Service Platform
// Copyright (c) 2012 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the License);
if (__pDir == null)
{
r = _NativeError::ConvertNativeErrorToResult(errno, true);
- SysLog(NID_IO, "[%s] Failed to open directory (%s).", GetErrorMessage(r), pDirPath.get());
+ SysSecureLogException(NID_IO, r, "[%s] Failed to open directory (%s).", GetErrorMessage(r), pDirPath.get());
goto CATCH;
}
return E_SUCCESS;
CATCH:
-
return r;
}
// By the time we are here.. we assume we have a legal path to create
// the below logic works under the assumption that the path name does not end with '/'
- ret = mkdir(pDirPath.get(), S_IRUSR | S_IWUSR | S_IXUSR);
+ ret = mkdir(pDirPath.get(), 0755);
if (ret == -1)
{
// if parent directory does not exist and if we are asked to create them
ret = rename(pOldpath.get(), pNewpath.get());
if (ret != 0)
{
- r = _NativeError::ConvertNativeErrorToResult(errno, true);
- SysLog(NID_IO, "errno[%d], [%s] could not rename dirpath [%s].", errno, GetErrorMessage(r), pOldpath.get());
+ switch (errno)
+ {
+ case EBUSY:
+ // fall through
+ case EMLINK:
+ r = E_IO;
+ break;
+ case ENOTEMPTY:
+ r = E_FILE_ALREADY_EXIST;
+ break;
+ case EXDEV:
+ r = E_INVALID_ARG;
+ break;
+ default:
+ r = _NativeError::ConvertNativeErrorToResult(errno, true);
+ break;
+ }
+ SysLogException(NID_IO, r, "[%s] Renaming the directory path (%s) is failed, errno: %d (%s)", GetErrorMessage(r), pOldpath.get(), errno, strerror(errno));
}
return r;
strcpy(absPath, pDirPath);
strcat(absPath, "/");
strcat(absPath, dirEnt.d_name);
- //SysLog(NID_IO, "entry name: %s", absPath);
- struct stat statbuf;
- memset(&statbuf, 0, sizeof(struct stat));
- if (lstat(absPath, &statbuf) == -1)
+ struct stat64 statbuf;
+ memset(&statbuf, 0, sizeof(struct stat64));
+ if (lstat64(absPath, &statbuf) == -1)
{
r = _NativeError::ConvertNativeErrorToResult(errno, true);
SysLog(NID_IO, "[%s] Failed to get file status. errno: %d (%s)",
}
if (!S_ISLNK(statbuf.st_mode))
{
- if (stat(absPath, &statbuf) < 0)
+ if (stat64(absPath, &statbuf) < 0)
{
r = _NativeError::ConvertNativeErrorToResult(errno, true);
SysLog(NID_IO, "[%s] Failed to get file status. errno: %d (%s)",