#include <runtime_info.h>
#include <vconf.h>
+#include <FAppApp.h>
#include <FBaseRtEvent.h>
#include <FBaseRtIEventArg.h>
#include <FBaseRtIEventListener.h>
}
char command[512] = {0,};
+ char fileName[512] = {0,};
long long size = 0;
int ret = 0;
- sprintf(command, "du -sk -P %s >> /tmp/size_of_directory.tmp", path);
+ Tizen::App::App* pApp = Tizen::App::App::GetInstance();
+ if(pApp == null)
+ {
+ return 0;
+ }
+
+ String appId(pApp->GetAppId());
+ unique_ptr <char> appIdPath(_StringConverter::CopyToCharArrayN(appId));
+
+ ret = sprintf(fileName, "/tmp/size_of_directory_%s.tmp", appIdPath.get());
+ if(ret < 1)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to write file path.");
+ return 0;
+ }
+
+ ret = sprintf(command, "rm -rf %s", fileName);
+ if(ret < 1)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to write remove command.");
+ return 0;
+ }
+
+ ret = system(command);
- system("rm -rf /tmp/size_of_directory.tmp");
- system(command);
+ if(ret == -1)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to execute command[%s].", command);
+ }
+
+ ret = sprintf(command, "du -skb -P %s >> %s", path, fileName);
+ if(ret < 1)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to write du command.");
+ return 0;
+ }
+
+ ret = system(command);
+ if(ret == -1)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to execute command[%s].", command);
+ return 0;
+ }
FILE* pFile = null;
- pFile = fopen("/tmp/size_of_directory.tmp", "r");
+ pFile = fopen(fileName, "r");
if(pFile == null)
{
return 0;
}
- ret = fscanf(pFile, "%lld", &size);
+ ret = fscanf(pFile, "%lld", &size);
if(ret < 1)
{
if(pFile != null)
{
fclose(pFile);
}
- system("rm -rf /tmp/size_of_directory.tmp");
+
+ ret = sprintf(command, "rm -rf %s", fileName);
+ if(ret < 1)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to write remove command.");
+ return 0;
+ }
+
+ ret = system(command);
+ if(ret == -1)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to execute command[%s].", command);
+ }
+
+
return size;
}
{
if(listener != null)
{
- SysLog(NID_SYS, "%x", listener);
- runtimeInfoEvent.AddListener(*listener, false);
+ runtimeInfoEvent.AddListener(*listener);
}
int thr_id = 0;
{
if(listener != null)
{
- SysLog(NID_SYS, "test %x", listener);
+ SysLog(NID_SYS, "listener instance is %x.", listener);
runtimeInfoEvent.AddListener(*listener);
}
pEventArg->DirectoryPath = directoryPath;
thr_id = pthread_create(&p_thread, null, GetDirectorySizeAsync, pEventArg);
- SysLog(NID_SYS, "%d", thr_id);
+ SysLog(NID_SYS, "Thread id is %d.", thr_id);
pthread_detach(p_thread);
}