*/
#include <stdlib.h>
+#include <aul/aul.h>
#include <FBaseSysLog.h>
#include <FAppApp.h>
#include <FBaseInteger.h>
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)
{
SysTryReturn(NID_CNT, pContentData != null, UuId::GetInvalidUuId(), E_INVALID_ARG,
"[E_INVALID_ARG] pContentData is null.");
- // Exception : E_SUCCESS, E_INVALID_ARG
+ String mimeType(L"");
String extension = _FileImpl::GetFileExtension(pContentData->contentPath);
result r = GetLastResult();
- SysTryReturn(NID_CNT, !(IsFailed(r)), UuId::GetInvalidUuId(), r, "[%s] Propagating.", GetErrorMessage(r));
+ if (IsFailed(r))
+ {
+ ClearLastResult();
+
+ SysLog(NID_CNT, "[%s] Failed to perform GetFileExtension operation.", GetErrorMessage(r));
+
+ unique_ptr<char[]> pTempPath(_StringConverter::CopyToCharArrayN(pContentData->contentPath));
+ SysTryReturn(NID_CNT, pTempPath != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ char tempType[255] = {0, };
+ int ret = aul_get_mime_from_file(pTempPath.get(), tempType, sizeof(tempType));
+ SysTryReturn(NID_CNT, ret == AUL_R_OK, UuId::GetInvalidUuId(), E_INVALID_ARG,
+ "[E_INVALID_ARG] Failed to perform aul_get_mime_from_file operation.");
+
+ r = mimeType.Append(tempType);
+ SysTryReturn(NID_CNT, !IsFailed(r), UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to perform Append operation.");
+
+ }
// If the content format is JPG and it has GPS data, it will be saved in database automatically.
- if (extension == L"jpg" || extension == L"jpeg" || extension == L"JPG" || extension == L"JPEG")
+ if (extension == L"jpg" || extension == L"jpeg" || extension == L"JPG" || extension == L"JPEG" || mimeType.Contains(L"jpeg"))
{
SysLog(NID_CNT, "The format of content is jpg.");
pContentData->longitude = pImageMetadata->GetLongitude();
delete pImageMetadata;
- pImageMetadata = null;
}
}