+wrt-commons (0.2.67) unstable; urgency=low
+
+ * Localization cleaning from unused API (restore)
+ * Removing old, unused _WrtUtil* functions
+ * Database reset affects security-server
+ * Removing FileUtils
+ * Replacing recursive opendir with fts
+
+ * Release wrt-commons_0.2.67
+
+ * Git : framework/web/wrt-commons
+ * Tag : wrt-commons_0.2.67
+
+ -- Soyoung Kim <sy037.kim@samsung.com> Wed, 24 Oct 2012 17:02:50 +0900
+
wrt-commons (0.2.66) unstable; urgency=low
* Release wrt-commons_0.2.66
chown 0:6026 /opt/dbspace/.$name.db-journal
chmod 660 /opt/dbspace/.$name.db
chmod 660 /opt/dbspace/.$name.db-journal
+ pkill -9 security-serv
done
#
SET(DPL_LOCALIZATION_SOURCES
- ${PROJECT_SOURCE_DIR}/modules/localization/src/localization_utils.cpp
${PROJECT_SOURCE_DIR}/modules/localization/src/w3c_file_localization.cpp
${PROJECT_SOURCE_DIR}/modules/localization/src/LanguageTagsProvider.cpp
PARENT_SCOPE
typedef DPL::Optional<WidgetIcon> OptionalWidgetIcon;
typedef DPL::Optional<WidgetStartFileInfo> OptionalWidgetStartFileInfo;
-namespace LocalizationUtils {
-/* Function below is deprecated - please use static functions of LanguageTagsProvider:
- * BCP47LanguageTagToLocale() and LocaleToBCP47LanguageTag() */
-DPL::String BCP47LanguageTagToLocale(const DPL::String&) __attribute__((deprecated));
-
-}
#endif //LOCALIZATION_UTILS_H
std::string filePath)
{
LogDebug("Looking for file: " << filePath << " in: " << basePath);
- using namespace LocalizationUtils;
const LanguageTags& ltags = LanguageTagsProviderSingleton::Instance().getLanguageTags();
DPL::OptionalString getStartFile(WrtDB::WidgetDAOReadOnlyPtr dao)
{
- using namespace LocalizationUtils;
-
WidgetDAOReadOnly::LocalizedStartFileList locList = dao->getLocalizedStartFileList();
WidgetDAOReadOnly::WidgetStartFileList list = dao->getStartFileList();
LanguageTags tagsList = LanguageTagsProviderSingleton::Instance().getLanguageTags();
OptionalWidgetIcon getIcon(const WrtDB::DbWidgetHandle widgetHandle)
{
- using namespace LocalizationUtils;
WidgetDAOReadOnly dao(widgetHandle);
WidgetDAOReadOnly::WidgetLocalizedIconList locList = dao.getLocalizedIconList();
WidgetIconList getValidIconsList(
WrtDB::DbWidgetHandle widgetHandle)
{
- using namespace LocalizationUtils;
WidgetDAOReadOnly dao(widgetHandle);
WidgetDAOReadOnly::WidgetIconList list = dao.getIconList();
OptionalWidgetStartFileInfo getStartFileInfo(
WrtDB::DbWidgetHandle widgetHandle)
{
- using namespace LocalizationUtils;
-
WidgetStartFileInfo info;
WidgetDAOReadOnly dao(widgetHandle);
SET(DPL_UTILS_SOURCES
${PROJECT_SOURCE_DIR}/modules/utils/src/bash_utils.cpp
- ${PROJECT_SOURCE_DIR}/modules/utils/src/file_utils.cpp
${PROJECT_SOURCE_DIR}/modules/utils/src/folder_size.cpp
${PROJECT_SOURCE_DIR}/modules/utils/src/mime_type_utils.cpp
${PROJECT_SOURCE_DIR}/modules/utils/src/warp_iri.cpp
SET(DPL_UTILS_HEADERS
${PROJECT_SOURCE_DIR}/modules/utils/include/dpl/utils/bash_utils.h
- ${PROJECT_SOURCE_DIR}/modules/utils/include/dpl/utils/file_utils.h
${PROJECT_SOURCE_DIR}/modules/utils/include/dpl/utils/folder_size.h
${PROJECT_SOURCE_DIR}/modules/utils/include/dpl/utils/mime_type_utils.h
${PROJECT_SOURCE_DIR}/modules/utils/include/dpl/utils/warp_iri.h
* limitations under the License.
*/
/**
- * @file wrt_utility.h
- * @version 0.6
- * @author Wei Dong(d.wei@samsung.com)
- * @author Ma Quan(jason.ma@samsung.com)
- * @brief Header file of widget manager common functions
+ * @file wrt_utility.h
+ * @version 0.8
+ * @author Janusz Majnert <j.majnert@samsung.com>
+ * @brief Common utility functions
*/
#ifndef _WRT_UTILITY_H_
#define _WRT_UTILITY_H_
-#include <stdbool.h>
#include <sys/stat.h>
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/**
- * File options
- */
-enum
-{
- WRT_FILEUTILS_RECUR = 4 //this is the default for almost all WrtMakeDir calls (once called with 0)
-};
-
-/**
- * Combine the parentPath and fileName into a new absolute file name.
- *
- * @param[out] absolutePath
- * @param[in] parentPath
- * @param[in] fileName
- *
- * @return if success, return true; or return false.
- */
-bool _WrtUtilSetAbsolutePath(char* absolutePath,
- const char* parentPath,
- const char* fileName);
-
/**
* Joins two paths into one
*
*/
void WrtUtilJoinPaths(std::string &joined, const std::string &parent, const std::string &child);
-/**
- * This function is used to make a directory.
- * it's neccessary to free the returned dir path.
- *
- * @param[in] path Specified the directory path
- * @param[in] mode Operation mode the you want to set
- * @param[in] flags WRT_FILEUTILS_RECUR if you want to make parent's directory recusively,
- * WRT_FILEUTILS_NONE if not.
- *
- * @return TRUE on success or FALSE on failure.
- */
-bool _WrtMakeDir (const char *path,
- long mode,
- int flags);
-
/**
* Creates directories specified by path
*
*/
bool WrtUtilMakeDir(const std::string &newpath, mode_t mode=0755);
-/**
- * This function is used to remove a directory from the file system.
- *
- * @param[in] path Specified the directory path
- *
- * @return TRUE on success or FALSE on failure.
- */
-bool _WrtUtilRemoveDir(const char* path);
-
/**
* This function removes the directory or file pointed to by path
*
*/
bool WrtUtilRemove(const std::string &path);
-/**
- * This function is used to convert a string to lowercase.
- *
- * @param[in] str the string need to be converted.
- * @param[in] lowerStr the converted string.
- *
- * @return TRUE on success or FALSE on failure.
- */
-bool _WrtUtilStringToLower(const char* str,
- char** lowerStr);
-
/**
* This function converts a string to lowercase
*
*/
bool WrtUtilDirExists(const std::string &path);
-#ifdef __cplusplus
-}
-#endif
-
#endif //_WRT_UTILITY_H_
*/
#include <string.h>
-#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <fts.h>
#include <sstream>
#include <vector>
#include <dpl/utils/folder_size.h>
namespace Utils {
-namespace {
-
-size_t getObjectSize(const std::string& path)
-{
- struct stat tmp;
-
- if (stat(path.c_str(), &tmp) == -1) {
- LogError("Failed to open file" << path);
- return 0;
- }
- //it is not a file nor a directory
- //not counting
- if (!S_ISDIR(tmp.st_mode) && !S_ISREG(tmp.st_mode)) {
- LogWarning("Not a regular file nor a directory: " << path);
- return 0;
- }
- return tmp.st_size;
-}
-}
size_t getFolderSize(const std::string& path)
{
size_t size = 0;
-
- DIR *dir;
- std::vector<std::string> localDirs;
- if ((dir=opendir(path.c_str())) == NULL) {
- LogError("Cannot open dir " << path);
+ FTS *fts;
+ FTSENT *ftsent;
+ char * const paths[] = {const_cast<char * const>(path.c_str()), NULL};
+
+ if ((fts = fts_open(paths, FTS_PHYSICAL|FTS_NOCHDIR, NULL)) == NULL) {
+ //ERROR
+ int error = errno;
+ LogWarning(__PRETTY_FUNCTION__ << ": fts_open failed with error: "
+ << strerror(error));
return 0;
}
- struct dirent* el;
- while ((el = readdir(dir)) != 0) {
- if (strcmp(el->d_name, ".") == 0 || strcmp(el->d_name, "..") == 0) {
- continue;
- }
- struct stat tmp;
- std::string local = path + el->d_name;
- if (stat(local.c_str(), &tmp) == -1) {
- LogError("Failed to open file " << local);
- char* errstring = strerror(errno);
- LogError("Reason: " << errstring);
- continue;
- }
- size += getObjectSize(local);
- if (S_ISDIR(tmp.st_mode)) {
- localDirs.push_back(local + "/");
+ while ((ftsent = fts_read(fts)) != NULL) {
+ switch (ftsent->fts_info) {
+ case FTS_DP:
+ case FTS_DC:
+ //directory in postorder and directory causing a loop
+ break;
+ case FTS_F:
+ case FTS_D:
+ case FTS_NSOK:
+ case FTS_SL:
+ case FTS_SLNONE:
+ case FTS_DEFAULT:
+ //regular files and other objects that can be counted
+ size += ftsent->fts_statp->st_size;
+ break;
+ case FTS_NS:
+ case FTS_DOT:
+ case FTS_DNR:
+ case FTS_ERR:
+ default:
+ LogWarning(__PRETTY_FUNCTION__
+ << ": traversal failed on file: "
+ << ftsent->fts_path
+ << " with error: "
+ << strerror(ftsent->fts_errno));
+ return 0;
}
}
- closedir(dir);
-
- FOREACH (localDir, localDirs) {
- size += getFolderSize(*localDir);
+ if (fts_close(fts) == -1) {
+ int error = errno;
+ LogWarning(__PRETTY_FUNCTION__ << ": fts_close failed with error: "
+ << strerror(error));
+ return 0;
}
return size;
* limitations under the License.
*/
/**
- * @file wrt_utility.cpp
- * @version 0.6
- * @author Wei Dong(d.wei@samsung.com)
- * @author Ma Quan(jason.ma@samsung.com)
- * @brief This file implemented some common functions for widget manager
+ * @file wrt_utility.cpp
+ * @version 0.8
+ * @author Janusz Majnert <j.majnert@samsung.com>
+ * @brief Implementation of some common utility functions
*/
-#include <stdio.h>
-#include <dirent.h>
-#include <errno.h>
-#include <libgen.h>
#include <fts.h>
-#include <sys/types.h>
+#include <string>
#include <sys/stat.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <ctype.h>
#include <dpl/log/log.h>
#include <dpl/utils/wrt_utility.h>
-#ifndef MAX_WIDGET_PATH_LENGTH
-#define MAX_WIDGET_PATH_LENGTH 1024
-#endif
-
-//will be replaced by WrtUtilJoinPaths
-bool _WrtUtilSetAbsolutePath(char* absolutePath,
- const char* parentPath,
- const char* fileName)
-{
- int len;
- if (NULL == absolutePath || NULL == parentPath || NULL == fileName) {
- return false;
- }
- len = strlen(parentPath);
- if (len > 0) {
- // not check the valid of parentPath and fileName.
- if (parentPath[len - 1] == '/') {
- snprintf(absolutePath,
- MAX_WIDGET_PATH_LENGTH,
- "%s%s",
- parentPath,
- fileName);
- } else {
- snprintf(absolutePath,
- MAX_WIDGET_PATH_LENGTH,
- "%s/%s",
- parentPath,
- fileName);
- }
- } else {
- LogDebug("The parent path is null");
- return false;
- }
-
- //some widget use Windows notation. We need to change '\' to '/'
- for (int i = 0; absolutePath[i] != 0; ++i) {
- if (absolutePath[i] == '\\') {
- absolutePath[i] = '/';
- }
- }
-
- return true;
-}
-
void WrtUtilJoinPaths(std::string &joined, const std::string &parent, const std::string &child)
{
size_t parent_len = parent.length();;
}
}
-// check it deeply later.
-bool _WrtMakeDir (const char *path,
- long mode,
- int flags)
-{
- if (NULL == path) {
- return false;
- }
-
- const int defaultMode = 0777;
- if (!(flags & WRT_FILEUTILS_RECUR)) {
- if (mkdir(path, defaultMode) < 0) {
- LogDebug("Failed to make dir " << path);
- return false;
- }
- if (mode != -1 && chmod(path, mode) < 0) {
- LogDebug("Failed to chmod");
- remove(path);
- return false;
- }
- } else {
- struct stat st;
- if (stat(path, &st) < 0 && errno == ENOENT) {
- bool ret;
- char *buf = NULL;
- char *parent = NULL;
- // mode_t mask;
-
- // mask = umask (0);
- // umask (mask);
-
- buf = strdup(path);
- parent = dirname(buf);
- //ret = _WrtMakeDir(parent, (defaultMode & ~mask) | 0300, WRT_FILEUTILS_RECUR);
- ret = _WrtMakeDir(parent, (defaultMode) | 0300, WRT_FILEUTILS_RECUR);
- free(buf);
-
- if ((!ret) || (!_WrtMakeDir(path, mode, 0))) {
- LogDebug("Failed to _WrtMakeDir");
- return false;
- }
- }
- }
-
- return true;
-}
-
bool WrtUtilMakeDir(const std::string &newpath, mode_t mode)
{
size_t pos = 0;
return true;
}
-// will be replaced with the latter function
-bool _WrtUtilRemoveDir(const char* path)
-{
- DIR* dir = NULL;
- struct dirent* ptr = NULL;
- char childPath[MAX_WIDGET_PATH_LENGTH + 1] = { 0 };
- if (path == NULL) {
- LogWarning("Path is null");
- return false;
- }
- dir = opendir(path);
- if (NULL != dir) {
- while ((ptr = readdir(dir)) != NULL) {
- if ((!strcmp(ptr->d_name, ".")) || (!strcmp(ptr->d_name, ".."))) {
- continue;
- }
- int len = strlen(path);
- if (path[len - 1] == '/') {
- snprintf(childPath,
- MAX_WIDGET_PATH_LENGTH,
- "%s%s",
- path,
- ptr->d_name);
- } else {
- snprintf(childPath,
- MAX_WIDGET_PATH_LENGTH,
- "%s/%s",
- path,
- ptr->d_name);
- }
- if (ptr->d_type == DT_DIR) {
- if (!_WrtUtilRemoveDir(childPath)) {
- closedir(dir);
- return false;
- }
- } else {
- if (unlink(childPath) != 0) {
- closedir(dir);
- LogWarning("Failed to remove file " << childPath);
- return false;
- }
- }
- }
- closedir(dir);
- } else if (errno == ENOTDIR) {
- if (unlink(path) != 0) {
- LogWarning("Failed to remove file " << path);
- return false;
- }
- return true;
- } else if (errno == ENOENT) { //not exist
- LogWarning("Cannot remove non existent directory " << path);
- return true;
- } else {
- LogWarning("Can't remove directory " << path);
- return false;
- }
- if (rmdir(path) != 0) {
- LogWarning("Removing directory failed :" << path << " errno: " << errno);
- return false;
- }
-
- return true;
-}
-
bool WrtUtilRemove(const std::string &path)
{
FTS *fts;
return rv;
}
-// shall be replaced with the latter function
-bool _WrtUtilStringToLower(const char* str, char** lowerStr)
-{
- if (!str || !lowerStr) {
- return true;
- }
-
- char* cur = NULL;
- int length = strlen(str);
-
- *lowerStr = (char*)malloc(length + 1);
-
- if (!(*lowerStr)) {
- return false;
- }
-
- memset(*lowerStr, 0, length + 1);
- strncpy(*lowerStr, str, length);
-
- cur = *lowerStr;
-
- while (*str != '\0') {
- *cur++ = tolower(*str++);
- //cur++;
- }
-
- return true;
-}
-
void WrtUtilStringToLower(std::string &out, const std::string &in)
{
out.clear();
-#sbs-git:slp/pkgs/w/wrt-commons wrt-commons 0.2.66
+#sbs-git:slp/pkgs/w/wrt-commons wrt-commons 0.2.67
Name: wrt-commons
Summary: Wrt common library
-Version: 0.2.66
+Version: 0.2.67
Release: 1
Group: Development/Libraries
License: Apache License, Version 2.0