__pContext->__inputPath = newPath;
__pContext->__installDir = newPath;
+ __pContext->__packageSize = InstallerUtil::GetDisplaySize(newPath);
}
else
{
installerType = INSTALLER_TYPE_PACKAGE;
__pContext->__packagePath = newPath;
+ __pContext->__packageSize = InstallerUtil::GetDisplaySize(newPath);
}
if (pOptionalData)
pPackageId = __pContext->__packageId.GetPointer();
}
- const wchar_t* pMainAppName = L"Unknown";
- if (!__pContext->__mainAppName.IsEmpty())
+ const wchar_t* pPackageSize = L"0 B";
+ if (!__pContext->__packageSize.IsEmpty())
{
- pMainAppName = __pContext->__mainAppName.GetPointer();
+ pPackageSize = __pContext->__packageSize.GetPointer();
}
- const char* pError = null;
- (errorType == 0)?(pError = "Success"):(pError = "Failure");
+ const wchar_t* pAppInfoStr = L"Unknown";
+ String appInfoStr = GetAppInfoString();
+ if (!appInfoStr.IsEmpty())
+ {
+ pAppInfoStr = appInfoStr.GetPointer();
+ }
+ String error = GetErrorString(errorType);
int duration = (int)(__endTick - __startTick);
AppLog("==========================================");
- AppLog(" # operation = %s", pOperation);
- AppLog(" # %s", OSP_INSTALLER_VERSION);
- AppLog(" # Package = [%ls]", pPackageId);
- AppLog(" # MainApp = [%ls]", pMainAppName);
+ AppLog(" # osp-installer: %s", OSP_INSTALLER_VERSION);
+ AppLog("------------------------------------------");
+ AppLog(" # Operation = [%s]", pOperation);
+ AppLog(" # Package = [%ls](%ls)", pPackageId, pPackageSize);
+ AppLog(" # Apps = [%ls]", pAppInfoStr);
AppLog(" # Time = [%d]ms", duration);
- PrintError(errorType);
+ AppLog(" # Result = [%ls(%03d)]", error.GetPointer(), errorType);
AppLog("==========================================");
- fprintf(stderr, " ## osp-installer: operation=[%s] result=[%s(%03d)] package=[%ls] main appname=[%ls] time=[%d]ms\n",
- pOperation, pError, errorType, pPackageId, pMainAppName, duration);
+ fprintf(stderr, " ## osp-installer: package=[%ls](%ls) operation=[%s] result=[%ls](%03d)\n",
+ pPackageId, pPackageSize, pOperation, error.GetPointer(), errorType);
+ fprintf(stderr, " ## osp-installer: apps=[%ls] time=[%d]ms\n", pAppInfoStr, duration);
}
-void
-InstallerManager::PrintError(int errorType)
+String
+InstallerManager::GetErrorString(int errorType)
{
const char* pError = null;
break;
}
- AppLog(" # Error = %s(%d)", pError, errorType);
+ String error = pError;
+ return error;
+}
+
+String
+InstallerManager::GetAppInfoString()
+{
+ String appInfoStr;
+ TryReturn(__pContext, appInfoStr, "__pContext is null");
+
+ String appRootPath = __pContext->__rootPath;
+
+ IListT<AppData*>* pAppDataList = __pContext->__pAppDataList;
+ TryReturn(pAppDataList, appInfoStr, "pAppDataList is null.");
+
+ for (int i = 0 ; i < pAppDataList->GetCount(); i++)
+ {
+ AppData* pAppData = null;
+ pAppDataList->GetAt(i, pAppData);
+ TryReturn(pAppData, appInfoStr, "pAppData is null.");
+
+ String destPath = appRootPath + DIR_BIN + L"/" + pAppData->__name + L".exe";
+
+ if (i != 0)
+ {
+ appInfoStr += L" ";
+ }
+
+ appInfoStr += pAppData->__name;
+ if (pAppData->__main.Equals("True", false) == true)
+ {
+ appInfoStr += L"(main)";
+ }
+
+ String sizeStr = L"(" + InstallerUtil::GetDisplaySize(destPath) + L")";
+ appInfoStr += sizeStr;
+ }
+
+ return appInfoStr;
}
int
return false;
}
+
+long long
+InstallerUtil::GetDirectorySize(const String& rootPath)
+{
+ long long total = 0;
+ long long ret = 0;
+ int q = 0;
+ int r = 0;
+ DIR *dp = NULL;
+ struct dirent *ep = NULL;
+ struct stat fileinfo;
+ char file[FILENAME_MAX] = { 0, };
+ char *pDirName = null;
+
+ pDirName = _StringConverter::CopyToCharArrayN(rootPath);
+ TryCatch(pDirName, total = 0, "[osp-installer][libtpk] pDirName is null");
+
+ dp = opendir(pDirName);
+ TryCatch(dp, total = 0, "[osp-installer][libtpk] dp is null");
+
+ while ((ep = readdir(dp)) != NULL)
+ {
+ if (!strcmp(ep->d_name, ".") || !strcmp(ep->d_name, ".."))
+ {
+ continue;
+ }
+
+ snprintf(file, FILENAME_MAX, "%s/%s", pDirName, ep->d_name);
+
+ if (lstat(file, &fileinfo) < 0)
+ {
+ continue;
+ }
+
+ if (S_ISLNK(fileinfo.st_mode))
+ {
+ AppLog("SYMLINK=%s", file);
+ total += INSTALLER_BLOCK_SIZE;
+ continue;
+ }
+ else if (S_ISDIR(fileinfo.st_mode))
+ {
+ ret = GetDirectorySize(file);
+ ret += fileinfo.st_size;
+ total += ret;
+ AppLog("DIR=%s, size=%d[%d KB],", file, (int)ret, (int)(ret/1024));
+ }
+ else
+ {
+ /*It is a file. Calculate the actual size occupied (in terms of 4096 blocks)*/
+ q = (fileinfo.st_size / INSTALLER_BLOCK_SIZE);
+ r = (fileinfo.st_size % INSTALLER_BLOCK_SIZE);
+ if (r)
+ {
+ q++;
+ }
+ total += q * INSTALLER_BLOCK_SIZE;
+
+ if (q)
+ {
+ // AppLog("File=%s, size=%d[%d KB]", file, (q * INSTALLER_BLOCK_SIZE), (q * INSTALLER_BLOCK_SIZE)/1024);
+ }
+ }
+ }
+
+ closedir(dp);
+ dp = null;
+
+CATCH:
+ delete [] pDirName;
+
+ return total;
+}
+
+String
+InstallerUtil::GetDisplaySize(const Tizen::Base::String& path)
+{
+ long long int size = 0;
+ float sizeRes = 0.0;
+ String unitStr = L"0 B";
+ result r = E_SUCCESS;
+
+ FileAttributes attr;
+ r = File::GetAttributes(path, attr);
+ TryReturn(!IsFailed(r), unitStr, "File::GetAttributes() failed");
+
+ if (attr.IsDirectory())
+ {
+ size = GetDirectorySize(path);
+
+ // root directory
+ size += INSTALLER_BLOCK_SIZE;
+ AppLog("DIR=%ls, size=%d[%d KB],", path.GetPointer(), (int)size, (int)(size/1024));
+ }
+ else
+ {
+ size = attr.GetFileSize();
+ }
+
+ if (size >= 1024*1024*1024)
+ {
+ sizeRes = size / (1024*1024*1024.0);
+ unitStr = L"GB";
+ }
+ else if (size >= 1024*1024)
+ {
+ sizeRes = size / (1024*1024.0);
+ unitStr = L"MB";
+ }
+ else if (size >= 1024)
+ {
+ sizeRes = size / 1024.0;
+ unitStr = L"KB";
+ }
+ else
+ {
+ sizeRes = size;
+ unitStr = L"B";
+ }
+
+ String resStr;
+ resStr.Format(128, L"%.1f %ls", sizeRes, unitStr.GetPointer());
+
+ return resStr;
+}