X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fpersistence_client_library_backup_filelist.c;h=f87942dfd681c5edf3976ca59401e6520a2b8b4d;hb=e0bb5aa03610f6002a7f093753d8aad3ad4c257c;hp=c72b7393f9fc2a9adcac31eff3c31f1b0b4a14ee;hpb=fdd7c5149b3c611b805560240834b25ef11147cb;p=profile%2Fivi%2Fpersistence-client-library.git diff --git a/src/persistence_client_library_backup_filelist.c b/src/persistence_client_library_backup_filelist.c index c72b739..f87942d 100644 --- a/src/persistence_client_library_backup_filelist.c +++ b/src/persistence_client_library_backup_filelist.c @@ -333,9 +333,11 @@ int pclCreateFile(const char* path) { const char* delimiters = "/\n"; // search for blank and end of line char* tokenArray[24]; - char* thePath = (char*)path; + char thePath[DbPathMaxLen] = {0}; int numTokens = 0, i = 0, validPath = 1; - int handle = 0; + int handle = -1; + + strncpy(thePath, path, DbPathMaxLen); tokenArray[numTokens++] = strtok(thePath, delimiters); while(tokenArray[numTokens-1] != NULL ) @@ -371,18 +373,6 @@ int pclCreateFile(const char* path) strncat(createPath, "/", DbPathMaxLen-1); strncat(createPath, tokenArray[i], DbPathMaxLen-1); handle = open(createPath, O_CREAT|O_RDWR |O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH); - if(handle != -1) - { - if(handle < MaxPersHandle) - { - __sync_fetch_and_add(&gOpenFdArray[handle], FileOpen); // set open flag - } - else - { - close(handle); - handle = EPERS_MAXHANDLE; - } - } } else { @@ -590,9 +580,12 @@ int pclCreateBackup(const char* dstPath, int srcfd, const char* csumPath, const if(access(dstPath, F_OK) != 0) { + int handle = -1; char pathToCreate[DbPathMaxLen] = {0}; strncpy(pathToCreate, dstPath, DbPathMaxLen); - pclCreateFileAndPath(pathToCreate); + + handle = pclCreateFile(pathToCreate); + close(handle); // don't need the open file } // create checksum file and and write checksum @@ -693,60 +686,6 @@ int pclBackupNeeded(const char* path) -int pclCreateFileAndPath(const char* path) -{ - const char* delimiters = "/\n"; // search for blank and end of line - char* tokenArray[24]; - char* thePath = (char*)path; - char createPath[DbPathMaxLen] = {0}; - int numTokens = 0, i = 0, validPath = 1; - int rval = -1; - - tokenArray[numTokens++] = strtok(thePath, delimiters); - while(tokenArray[numTokens-1] != NULL ) - { - tokenArray[numTokens] = strtok(NULL, delimiters); - if(tokenArray[numTokens] != NULL) - { - numTokens++; - if(numTokens >= 24) - { - validPath = 0; - break; - } - } - else - { - break; - } - } - - if(validPath == 1) - { - snprintf(createPath, DbPathMaxLen, "/%s",tokenArray[0] ); - for(i=1; i no valid path to create:"), DLT_STRING(path)); - } - - return rval; -} - - - int pclGetPosixPermission(PersistencePermission_e permission) { int posixPerm = 0;