E_INVALID_ARG, "[E_INVALID_ARG] %ls is not compatible.", destinationPath.GetPointer());
result r = E_SUCCESS;
+ bool isCopy = false;
if (deleteSource) // move
{
// Exception : E_SUCCESS, E_INVALID_ARG, E_ILLEGAL_ACCESS, E_FILE_NOT_FOUND, E_FILE_ALREADY_EXIST, E_MAX_EXCEEDED, E_STORAGE_FULL, E_IO
r = _FileImpl::Copy(sourcePath, destinationPath, true);
SysTryReturn(NID_CNT, !IsFailed(r), UuId::GetInvalidUuId(), r, "[%s] Copying the file failed.", GetErrorMessage(r));
+
+ isCopy = true;
}
int val = 0;
CATCH:
result saveResult = GetLastResult();
- // If the destination file is made by this method, it should be deleted when error occurs.
- r = _FileImpl::Remove(destinationPath);
- SysLog(NID_CNT, "Remove[%s].", GetErrorMessage(r));
+ if (isCopy)
+ {
+ r = _FileImpl::Remove(destinationPath);
+ SysLog(NID_CNT, "Remove[%s].", GetErrorMessage(r));
+ }
+ else
+ {
+ r = _FileImpl::Move(destinationPath, sourcePath);
+ SysLog(NID_CNT, "Move[%s].", GetErrorMessage(r));
+ }
if (pMediaInfo != null)
{