bool OperationCallbackData::isCanceled() const
{
+ LoggerD("Enter");
return m_is_canceled;
}
void OperationCallbackData::setCallbackId(double cid)
{
+ LoggerD("Enter");
m_cid = cid;
}
double OperationCallbackData::getCallbackId() const
{
+ LoggerD("Enter");
return m_cid;
}
void OperationCallbackData::setHandle(long handle)
{
+ LoggerD("Enter");
m_handle = handle;
}
long OperationCallbackData::getHandle() const
{
+ LoggerD("Enter");
return m_handle;
}
void OperationCallbackData::setIsCanceled(bool canceled)
{
+ LoggerD("Enter");
m_is_canceled = canceled;
}
void OperationCallbackData::PostMessage(const char* msg) {
+ LoggerD("Enter");
instance_.PostMessage(msg);
}
ArchiveFilePtr OperationCallbackData::getArchiveFile() const
{
+ LoggerD("Enter");
return m_caller_instance;
}
void OperationCallbackData::setArchiveFile(ArchiveFilePtr caller)
{
+ LoggerD("Enter");
m_caller_instance = caller;
}
unsigned long long size = 0;
PlatformResult result = node->getSize(&size);
if (result.error_code() != ErrorCode::NO_ERROR) {
+ LoggerE("Fail node->getSize()");
return result;
}
if (0 == size) {
archive_file_ptr->setIsOpen(true);
result = archive_file_ptr->updateListOfEntries();
if (result.error_code() != ErrorCode::NO_ERROR) {
+ LoggerE("Fail archive_file_ptr->updateListOfEntries()");
return result;
}
}
ArchiveFileEntryPtrMapPtr GetEntriesCallbackData::getEntries() const
{
+ LoggerD("Entered");
return m_entries;
}
void GetEntriesCallbackData::setEntries(ArchiveFileEntryPtrMapPtr entries)
{
+ LoggerD("Entered");
m_entries = entries;
}
ArchiveFileEntryPtr GetEntryByNameCallbackData::getFileEntry() const
{
+ LoggerD("Entered");
return m_file_entry;
}
void GetEntryByNameCallbackData::setFileEntry(ArchiveFileEntryPtr entry)
{
+ LoggerD("Entered");
m_file_entry = entry;
}
void BaseProgressCallback::callSuccessCallbackOnMainThread()
{
+ LoggerD("Entered");
+
guint id = g_idle_add(BaseProgressCallback::callSuccessCallbackCB,
static_cast<void*>(this));
if (!id) {
gboolean BaseProgressCallback::callSuccessCallbackCB(void* data)
{
+ LoggerD("Entered");
+
BaseProgressCallback* callback = static_cast<BaseProgressCallback*>(data);
if (!callback) {
LoggerE("callback pointer is NULL");
void BaseProgressCallback::callProgressCallbackOnMainThread(const double progress,
ArchiveFileEntryPtr current_entry)
{
+ LoggerD("Entered");
+
ProgressHolder* ph = new(std::nothrow) ProgressHolder();
if(ph) {
gboolean BaseProgressCallback::callProgressCallbackCB(void* data)
{
+ LoggerD("Entered");
+
ProgressHolder* ph = static_cast<ProgressHolder*>(data);
if (!ph) {
LoggerE("ph is null");
ZipPtr zip;
PlatformResult result = archive_file_ptr->createZipObject(&zip);
if (result.error_code() != ErrorCode::NO_ERROR) {
+ LoggerE("archive_file_ptr->createZipObject()");
return result;
}
result = zip->addFile(callback);
if (result.error_code() != ErrorCode::NO_ERROR) {
+ LoggerE("zip->addFile()");
return result;
}
// it is needed to read entries from file
result = zip->close();
if (result.error_code() != ErrorCode::NO_ERROR) {
+ LoggerE("zip->close()");
return result;
}
filesystem::FilePtr ExtractAllProgressCallback::getDirectory() const
{
+ LoggerD("Entered");
return m_directory;
}
void ExtractAllProgressCallback::setDirectory(filesystem::FilePtr directory)
{
+ LoggerD("Entered");
m_directory = directory;
}
void ExtractAllProgressCallback::startedExtractingFile(unsigned long current_file_size)
{
+ LoggerD("Entered");
+
m_current_file_size = current_file_size;
m_current_file_extracted_bytes = 0;
}
void ExtractAllProgressCallback::extractedPartOfFile(unsigned long bytes_decompressed)
{
+ LoggerD("Entered");
+
m_current_file_extracted_bytes += bytes_decompressed;
updateOverallProgress(bytes_decompressed);
}
void ExtractAllProgressCallback::finishedExtractingFile()
{
+ LoggerD("Entered");
+
m_current_file_size = 0;
m_current_file_extracted_bytes = 0;
++m_files_extracted;
void ExtractAllProgressCallback::updateOverallProgress(unsigned long bytes_decompressed)
{
+ LoggerD("Entered");
+
m_overall_decompressed += bytes_decompressed;
m_progress_overall =
static_cast<double>(m_overall_decompressed + m_files_extracted) /
double ExtractAllProgressCallback::getCurrentFileProgress() const
{
+ LoggerD("Entered");
+
if(m_current_file_size > 0) {
return static_cast<double>(m_current_file_extracted_bytes) /
static_cast<double>(m_current_file_size);
double ExtractAllProgressCallback::getOverallProgress() const
{
+ LoggerD("Entered");
+
return m_progress_overall;
}
void ExtractAllProgressCallback::setExpectedDecompressedSize(unsigned long exp_dec_size)
{
+ LoggerD("Entered");
+
m_expected_decompressed_size = exp_dec_size;
}
unsigned long ExtractAllProgressCallback::getExpectedDecompressedSize() const
{
+ LoggerD("Entered");
+
return m_expected_decompressed_size;
}
void ExtractAllProgressCallback::setNumberOfFilesToExtract(unsigned long files_count)
{
+ LoggerD("Entered");
+
m_files_to_extract = files_count;
}
unsigned long ExtractAllProgressCallback::getNumberOfFilesToExtract() const
{
+ LoggerD("Entered");
+
return m_files_to_extract;
}
ArchiveFileEntryPtr ExtractEntryProgressCallback::getArchiveFileEntry()
{
+ LoggerD("Entered");
return m_archive_file_entry;
}
void ExtractEntryProgressCallback::setArchiveFileEntry(ArchiveFileEntryPtr afentry)
{
+ LoggerD("Entered");
m_archive_file_entry = afentry;
}
void ExtractEntryProgressCallback::setStripName(bool strip_name)
{
+ LoggerD("Entered");
m_strip_name = strip_name;
}
bool ExtractEntryProgressCallback::getStripName() const
{
+ LoggerD("Entered");
return m_strip_name;
}
void ExtractEntryProgressCallback::setStripBasePath(
const std::string& strip_base_path)
{
+ LoggerD("Entered");
m_strip_base_path = strip_base_path;
}
const std::string& ExtractEntryProgressCallback::getStripBasePath() const
{
+ LoggerD("Entered");
return m_strip_base_path;
}
UnZipPtr unzip;
PlatformResult result = archive_file_ptr->createUnZipObject(&unzip);
if (result.error_code() != ErrorCode::NO_ERROR) {
+ LoggerE("archive_file_ptr->createUnZipObject()");
return result;
}
#include "archive_extension.h"
#include "archive_instance.h"
+#include "common/logger.h"
// This will be generated from archive_api.js
extern const char kSource_archive_api[];
common::Extension* CreateExtension()
{
+ LoggerD("Enter");
return new ArchiveExtension;
}
ArchiveExtension::ArchiveExtension()
{
+ LoggerD("Enter");
SetExtensionName("tizen.archive");
SetJavaScriptAPI(kSource_archive_api);
}
ArchiveExtension::~ArchiveExtension()
{
+ LoggerD("Enter");
}
common::Instance* ArchiveExtension::CreateInstance()
{
+ LoggerD("Enter");
return new extension::archive::ArchiveInstance();
}
namespace archive {
Permission::Permission(bool r, bool w, bool rw, bool a){
+ LoggerD("Enter");
permission[0] = r;
permission[1] = w;
permission[2] = rw;
m_is_open(false),
m_overwrite(false)
{
+ LoggerD("Enter");
m_file_mode = file_mode;
}
PlatformResult ArchiveFile::extractAllTask(ExtractAllProgressCallback* callback)
{
+ LoggerD("Enter");
filesystem::FilePtr directory = callback->getDirectory();
if(!directory) {
unsigned long long size = 0;
PlatformResult result = m_file->getNode()->getSize(&size);
if (result.error_code() != ErrorCode::NO_ERROR) {
+ LoggerE("Fail m_file->getNode()->getSize()");
return result;
}
if(size == 0) {
UnZipPtr unzip;
result = createUnZipObject(&unzip);
if (result.error_code() != ErrorCode::NO_ERROR) {
+ LoggerE("Fail createUnZipObject()");
return result;
}
ArchiveFileEntryPtrMapPtr ArchiveFile::getEntryMap() const
{
+ LoggerD("Entered");
return m_entry_map;
}
void ArchiveFile::setCreatedAsNewEmptyArchive(bool new_and_empty)
{
+ LoggerD("Entered");
m_created_as_new_empty_archive = new_and_empty;
}
bool ArchiveFile::isCreatedAsNewEmptyArchive() const
{
+ LoggerD("Entered");
return m_created_as_new_empty_archive;
}
PlatformResult ArchiveFile::updateListOfEntries()
{
+ LoggerD("Entered");
// For explanation please see:
// ArchiveFile.h m_created_as_new_empty_archive description
//
UnZipPtr unzip;
result = createUnZipObject(&unzip);
if (result.error_code() != ErrorCode::NO_ERROR) {
+ LoggerD("Fail createUnZipObject()");
return result;
}
ArchiveFileEntryPtrMapPtr emap;
result = unzip->listEntries(&decompressedSize, &emap);
if (result.error_code() != ErrorCode::NO_ERROR) {
+ LoggerD("Fail unzip->listEntries()");
return result;
}
bool* out_is_directory,
std::string* out_matching_name)
{
+ LoggerD("Enter");
+
if(!m_entry_map) {
LoggerW("m_entry_map is NULL");
return false;
}
if(!set_name_exists) {
+ LoggerE("Fail: name do not exists");
return false;
}
}
unsigned int ConvertStringToCompressionLevel(const std::string& level) {
+ LoggerD("Entered");
+
if (kNoCompressionStr == level) {
return Z_NO_COMPRESSION;
} else if (kFastCompressionStr == level) {
}
void ArchiveInstance::GetWidgetPaths(const picojson::value& args, picojson::object& out) {
+ LoggerD("Entered");
+
std::string wgt_package_path =
*(common::VirtualFs::GetInstance().GetVirtualRootDirectory(kWgtPackagePathName));
std::string wgt_private_path =
*archive_file = it->second;
return PlatformResult(ErrorCode::NO_ERROR);
}
+ LoggerE("Failed: Priv is null");
return PlatformResult(ErrorCode::UNKNOWN_ERR, "Priv is null");
}
std::string bytesToReadableString(const size_t num_bytes)
{
+ LoggerD("Enter");
std::stringstream ss;
static const size_t one_mb = 1024 * 1024;
static const size_t one_kb = 1024;
PlatformResult fileModeToString(FileMode fm, std::string* fm_str)
{
+ LoggerD("Enter");
switch(fm) {
case FileMode::READ:
*fm_str = "r";
*fm_str = "a";
break;
default:
+ LoggerE("Unknown file mode");
return PlatformResult(ErrorCode::UNKNOWN_ERR, "Unknown file mode");
}
return PlatformResult(ErrorCode::NO_ERROR);
PlatformResult stringToFileMode(std::string fmString, FileMode* fm)
{
+ LoggerD("Enter");
if (!fmString.compare("r")) {
*fm = FileMode::READ;
return PlatformResult(ErrorCode::NO_ERROR);
}
// In widl it's "TypeMismatchError" so this exception used
// instead of InvalidValues
+ LoggerE("Invalid FileMode");
return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "Invalid FileMode");
}
// FilePtr fileReferenceToFile(JSContextRef context, JSValueRef fileReference)
// {
// auto g_ctx = GlobalContextManager::getInstance()->getGlobalContext(context);
-//
+//
// FilePtr file_ptr;
// try {
// file_ptr = JSFile::getPrivateObject(context, fileReference);
// std::string string_path =
// External::fromVirtualPath(virtual_path, g_ctx);
// LOGD("Path: %s", string_path.c_str());
-//
+//
// PathPtr path = Path::create(string_path);
// NodePtr node_ptr = Node::resolve(path);
// file_ptr = FilePtr(new File(node_ptr, File::PermissionList()));
// }
-//
+//
// return file_ptr;
// }
std::string& out_basepath,
std::string& out_name)
{
+ LoggerD("Enter");
const size_t filepath_len = filepath.length();
size_t name_end_index = filepath_len;
std::string removeDuplicatedSlashesFromPath(const std::string& path)
{
+ LoggerD("Enter");
const size_t path_len = path.length();
std::string out;
bool isDirectoryPath(const std::string& path)
{
+ LoggerD("Enter");
if(path.empty()) {
return false;
}
std::string removeTrailingDirectorySlashFromPath(const std::string& path)
{
+ LoggerD("Enter");
if(!isDirectoryPath(path)) {
return path;
}
std::string stripBasePathFromPath(const std::string& fullpath)
{
+ LoggerD("Enter");
const size_t location = fullpath.find_last_of("/\\");
if(std::string::npos == location) {
return fullpath;
const std::string& getArchiveErrorMessage(int errorCode)
{
+ LoggerD("Enter");
/**
* All errors are defined in minizip library in files:
* zip.h and unzip.h
std::string getBasePathFromPath(const std::string& fullpath)
{
+ LoggerD("Enter");
const std::string tmp_path = removeTrailingDirectorySlashFromPath(fullpath);
const size_t location = tmp_path.find_last_of("/\\");
if(std::string::npos == location) {
std::string getArchiveLogMessage(const int errorCode, const std::string &hint)
{
+ LoggerD("Enter");
std::stringstream ss;
ss << "Failed " << hint << " : " << getArchiveErrorMessage(errorCode) << ", " << errorCode;
return std::string(ss.str());
File::~File()
{
+ LoggerD("Enter");
}
NodePtr File::getNode() const
#define MAX_NODE_LENGTH 256
PlatformResult Node::checkPermission(const PathPtr &path, const std::string &mode, NodeType type, bool* granted)
{
+ LoggerD("Enter");
*granted = false;
switch (type)
DIR* dir = opendir(path->getFullPath().c_str());
if (!dir) {
- LoggerW("throw InvalidValuesException");
+ LoggerE("throw InvalidValuesException");
return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Node has been deleted from platform.");
}
if (closedir(dir) != 0) {
- LoggerW("throw InvalidValuesException");
+ LoggerE("throw InvalidValuesException");
return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Could not close platform node.");
}
*granted = true;
return PlatformResult(ErrorCode::NO_ERROR);
}
- LoggerW("throw InvalidValuesException");
+ LoggerE("throw InvalidValuesException");
return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "invalid mode");
}
break;
}
else
{
- LoggerW("throw InvalidValuesException");
+ LoggerE("throw InvalidValuesException");
return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "invalid mode");
}
switch (errno)
{
case EACCES:
- LoggerW("throw InvalidValuesException for file:[%s]", path->getFullPath().c_str());
+ LoggerE("throw InvalidValuesException for file:[%s]", path->getFullPath().c_str());
return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Node access denied");
break;
case ENOENT:
- LoggerW("throw NotFoundException for file:[%s]", path->getFullPath().c_str());
+ LoggerE("throw NotFoundException for file:[%s]", path->getFullPath().c_str());
return PlatformResult(ErrorCode::NOT_FOUND_ERR, "NotFoundError");
break;
default:
- LoggerW("throw IOException for file:[%s]", path->getFullPath().c_str());
+ LoggerE("throw IOException for file:[%s]", path->getFullPath().c_str());
return PlatformResult(ErrorCode::IO_ERR, "Platform exception fail");
}
}
if (!S_ISDIR(info.st_mode) & !S_ISREG(info.st_mode) && !S_ISLNK(info.st_mode)) {
- LoggerW("throw IOException for file:[%s]", path->getFullPath().c_str());
+ LoggerE("throw IOException for file:[%s]", path->getFullPath().c_str());
return PlatformResult(ErrorCode::IO_ERR, "Platform node is of unsupported type.");
}
if (S_ISLNK(info.st_mode)) {
PlatformResult result = stat(path, &syminfo);
if (result.error_code() != ErrorCode::NO_ERROR) {
+ LoggerE("Error: %s", result.message().c_str());
return result;
}
PlatformResult Node::getChild(const PathPtr& path, NodePtr* node)
{
+ LoggerD("Enter");
if (m_type != NT_DIRECTORY) {
LoggerW("throw IOException");
return PlatformResult(ErrorCode::IO_ERR, "Not a directory.");
PlatformResult Node::getChildNames(Node::NameList* out_name_list) const
{
+ LoggerD("Enter");
if (m_type != NT_DIRECTORY) {
- LoggerW("throw IOException");
+ LoggerE("throw IOException");
return PlatformResult(ErrorCode::IO_ERR, "Node is not directory.");
}
if ((m_perms & PERM_READ) == 0) {
- LoggerW("throw InvalidValuesException");
+ LoggerE("throw InvalidValuesException");
return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "No permission.");
}
DIR* dir = opendir(m_path->getFullPath().c_str());
if (!dir) {
- LoggerW("throw IOException");
+ LoggerE("throw IOException");
return PlatformResult(ErrorCode::IO_ERR, "Node has been deleted from platform.");
}
name_list.push_back(entry->d_name);
}
if (errno != 0) {
- LoggerW("throw IOException");
+ LoggerE("throw IOException");
return PlatformResult(ErrorCode::IO_ERR, "Error while reading directory.");
}
if (closedir(dir) != 0) {
- LoggerW("throw IOException");
+ LoggerE("throw IOException");
return PlatformResult(ErrorCode::IO_ERR, "Could not close platform node.");
}
PlatformResult Node::getChildNodes(NodeList* out_node_list) const
{
+ LoggerD("Enter");
+
if (m_type != NT_DIRECTORY) {
- LoggerW("Path %s Perm %d", m_path->getFullPath().c_str(), m_perms);
- LoggerW("throw IOException");
- LoggerW("Path %s Perm %d", m_path->getFullPath().c_str(), m_perms);
+ LoggerE("Path %s Perm %d", m_path->getFullPath().c_str(), m_perms);
+ LoggerE("throw IOException");
+ LoggerE("Path %s Perm %d", m_path->getFullPath().c_str(), m_perms);
return PlatformResult(ErrorCode::IO_ERR, "Node is not directory.");
}
if ((m_perms & PERM_READ) == 0) {
- LoggerW("Path %s Perm %d", m_path->getFullPath().c_str(), m_perms);
- LoggerW("throw InvalidValuesException");
+ LoggerE("Path %s Perm %d", m_path->getFullPath().c_str(), m_perms);
+ LoggerE("throw InvalidValuesException");
return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "No permission.");
}
DIR* dir = opendir(m_path->getFullPath().c_str());
if (!dir) {
- LoggerW("Path %s Perm %d", m_path->getFullPath().c_str(), m_perms);
- LoggerW("throw IOException");
+ LoggerE("Path %s Perm %d", m_path->getFullPath().c_str(), m_perms);
+ LoggerE("throw IOException");
return PlatformResult(ErrorCode::IO_ERR, "Node has been deleted from platform.");
}
}
if (errno != 0) {
- LoggerW("Path %s Perm %d", m_path->getFullPath().c_str(), m_perms);
- LoggerW("throw IOException");
+ LoggerE("Path %s Perm %d", m_path->getFullPath().c_str(), m_perms);
+ LoggerE("throw IOException");
return PlatformResult(ErrorCode::IO_ERR, "Error while reading directory.");
}
if (closedir(dir) != 0) {
- LoggerW("Path %s Perm %d", m_path->getFullPath().c_str(), m_perms);
- LoggerW("throw IOException");
+ LoggerE("Path %s Perm %d", m_path->getFullPath().c_str(), m_perms);
+ LoggerE("throw IOException");
return PlatformResult(ErrorCode::IO_ERR, "Could not close platform node.");
}
NodePtr* node,
int options)
{
+ LoggerD("Enter");
if (m_type != NT_DIRECTORY) {
- LoggerW("throw IOException");
+ LoggerE("throw IOException");
return PlatformResult(ErrorCode::IO_ERR, "Parent node is not a directory.");
}
if ((m_perms & PERM_WRITE) == 0) {
- LoggerW("throw InvalidValuesException");
+ LoggerE("throw InvalidValuesException");
return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Not enough permissions.");
}
bool existed;
PlatformResult result = exists(childPath, &existed);
if (result.error_code() != ErrorCode::NO_ERROR) {
+ LoggerE("Fail: exists()");
return result;
}
if (existed) {
- LoggerW("throw IOException");
+ LoggerE("throw IOException");
return PlatformResult(ErrorCode::IO_ERR, "Node already exists.");
}
result = createAsDirectory(childPath, node, options);
break;
default:
- LoggerW("throw IOException");
+ LoggerE("throw IOException");
return PlatformResult(ErrorCode::IO_ERR, "Unsupported node type.");
}
if (result.error_code() != ErrorCode::NO_ERROR) {
+ LoggerE("Fail CreateAs...()");
return result;
}
if (!!(*node)) {
(*node)->m_perms = m_perms;
} else {
- LoggerW("throw IOException");
+ LoggerE("throw IOException");
return PlatformResult(ErrorCode::IO_ERR, "Node creation error");
}
PlatformResult Node::remove(int options)
{
+ LoggerD("Enter");
PlatformResult result(ErrorCode::NO_ERROR);
switch (m_type) {
case NT_FILE:
PlatformResult Node::getSize(unsigned long long* size) const
{
+ LoggerD("Enter");
if (m_type == NT_DIRECTORY) {
- LoggerW("Getting size for directories is not supported.");
- LoggerW("throw IOException");
+ LoggerE("Getting size for directories is not supported.");
+ LoggerE("throw IOException");
return PlatformResult(ErrorCode::IO_ERR, "Getting size for directories is not supported.");
}
struct stat info;
PlatformResult result = stat(m_path, &info);
if (result.error_code() != ErrorCode::NO_ERROR) {
+ LoggerE("Fail: stat()");
return result;
}
if (!S_ISREG(info.st_mode)) {
- LoggerW("Specified node is not a regular file.");
- LoggerW("throw IOException");
+ LoggerE("Specified node is not a regular file.");
+ LoggerE("throw IOException");
return PlatformResult(ErrorCode::IO_ERR, "Specified node is not a regular file.");
}
PlatformResult Node::getCreated(std::time_t* time) const
{
+ LoggerD("Enter");
struct stat info;
PlatformResult result = stat(m_path, &info);
if (result.error_code() != ErrorCode::NO_ERROR) {
+ LoggerE("Fail: stat()");
return result;
}
*time = info.st_ctime;
PlatformResult Node::getModified(std::time_t* time) const
{
+ LoggerD("Enter");
struct stat info;
PlatformResult result = stat(m_path, &info);
if (result.error_code() != ErrorCode::NO_ERROR) {
+ LoggerE("Fail: stat()");
return result;
}
*time = info.st_mtime;
// TODO Optimize it, maybe store a flag indicating that node is a root.
PlatformResult Node::getParent(NodePtr* node) const
{
+ LoggerD("Enter");
+
// LocationPaths roots = Manager::getInstance().getLocationPaths();
// for (LocationPaths::iterator it = roots.begin(); it != roots.end(); ++it) {
// if (*(*it) == *m_path) {
PlatformResult Node::getMode(int* mode) const
{
+ LoggerD("Enter");
+
struct stat info;
PlatformResult result = stat(m_path, &info);
if (result.error_code() == ErrorCode::NO_ERROR) {
PlatformResult Node::exists(const PathPtr& path, bool* existed)
{
+ LoggerD("Enter");
+
struct stat info;
memset(&info, 0, sizeof(struct stat));
int status = lstat(path->getFullPath().c_str(), &info);
}
else if (ENAMETOOLONG == errno)
{
- LoggerW("throw IOException");
+ LoggerE("throw IOException");
return PlatformResult(ErrorCode::IO_ERR, "file name is too long");
}
else if (errno != ENOENT)
PlatformResult Node::stat(const PathPtr& path, struct stat* out_info)
{
+ LoggerD("Enter");
struct stat info;
memset(&info, 0, sizeof(struct stat));
if (::stat(path->getFullPath().c_str(), &info) != 0)
{
LoggerE("File: %s", path->getFullPath().c_str());
- LoggerW("throw IOException");
+ LoggerE("throw IOException");
return PlatformResult(ErrorCode::IO_ERR, "Node does not exist or no access");
}
*out_info = info;
m_type(type),
m_perms(PERM_NONE)
{
+ LoggerD("Enter");
}
PlatformResult Node::createAsFile(const PathPtr& path, NodePtr* node, int /* options */)
{
+ LoggerD("Enter");
+
PlatformResult result = createAsFileInternal(path);
if (result.error_code() == ErrorCode::NO_ERROR) {
node->reset(new Node(path, NT_FILE));
PlatformResult Node::createAsFileInternal(const PathPtr& path)
{
+ LoggerD("Enter");
+
FILE* file = std::fopen(path->getFullPath().c_str(), "wb");
if (!file) {
- LoggerW("fopen fails IOException throw for path [%s]",
+ LoggerE("fopen fails IOException throw for path [%s]",
path->getFullPath().c_str());
return PlatformResult(ErrorCode::IO_ERR, "Platform node could not be created.");
}
PlatformResult Node::createAsDirectory(const PathPtr& path, NodePtr* node, int options)
{
+ LoggerD("Enter");
+
// if (options & OPT_RECURSIVE) {
// auto parts = Utils::getParts(path);
// for (auto it = parts.begin(); it != parts.end(); ++it) {
PlatformResult Node::createAsDirectoryInternal(const PathPtr& path)
{
+ LoggerD("Enter");
+
if (mkdir(path->getFullPath().c_str(), S_IRWXU | S_IRWXG | S_IROTH |
S_IXOTH) != 0) {
- LoggerW("throw IOException");
+ LoggerE("throw IOException");
return PlatformResult(ErrorCode::IO_ERR, "Platform node could not be created.");
}
return PlatformResult(ErrorCode::NO_ERROR);
PlatformResult Node::removeAsFile(const PathPtr& path)
{
+ LoggerD("Enter");
+
auto fullPath = path->getFullPath();
if (unlink(fullPath.c_str()) != 0) {
- LoggerW("remove [%s]", fullPath.c_str());
- LoggerW("throw IOException");
+ LoggerE("remove [%s]", fullPath.c_str());
+ LoggerE("throw IOException");
return PlatformResult(ErrorCode::IO_ERR, "Error while removing platform node.");
}
return PlatformResult(ErrorCode::NO_ERROR);
PlatformResult Node::removeAsDirectory(const PathPtr& path, bool recursive)
{
+ LoggerD("Enter");
+
if (recursive) {
DIR* dir = opendir(path->getFullPath().c_str());
if (!dir) {
- LoggerW("File %s", path->getFullPath().c_str());
- LoggerW("throw IOException");
+ LoggerE("File %s", path->getFullPath().c_str());
+ LoggerE("throw IOException");
return PlatformResult(ErrorCode::IO_ERR, "Node does not exist or access denied.");
}
errno = 0;
result = removeAsFile(subPath);
}
if (result.error_code() != ErrorCode::NO_ERROR) {
+ LoggerE("Fail: getFullPath() (%d)",result.error_code());
return result;
}
}
errno = 0;
if (rmdir(path->getFullPath().c_str()) != 0) {
if (errno == EEXIST) {
- LoggerW("throw IOException");
+ LoggerE("throw IOException");
return PlatformResult(ErrorCode::IO_ERR, "Node has child nodes.");
}
- LoggerW("throw IOException");
+ LoggerE("throw IOException");
return PlatformResult(ErrorCode::IO_ERR, "Error while removing platform node.");
}
std::string Node::toUri(int /*widgetId*/) const
{
+ LoggerD("Enter");
// TODO I believe moving this feature to WrtWrapper would make more sense.
return "file://" + m_path->getFullPath();
}
bool Node::isSubPath(std::string aDirPath, PathPtr aFilePath)
{
+ LoggerD("Enter");
auto myPath = aDirPath;
if(!myPath.empty() && myPath[myPath.length()-1] != Path::getSeparator()) {
myPath += Path::getSeparator();
PathPtr Path::create(const std::string& path)
{
+ LoggerD("Enter");
auto result = std::shared_ptr<Path>(new Path());
result->reset(path);
return result;
void Path::reset(const std::string& str)
{
+ LoggerD("Enter");
if (!isValid(str)) {
LoggerD("Invalid string %s", str.c_str());
LoggerW("throw NotFoundException");
// The only way to remove throw statement from here is to just return, because
- // this function is used in the operator functions and they're not able
+ // this function is used in the operator functions and they're not able
// to handle a PlatformResult value;
return;
}
m_default_buffer_size(1024 * 1024)
{
LoggerD("Entered");
-
m_unzip = unzOpen(filename.c_str());
}
UnZip::~UnZip()
{
+ LoggerD("Enter");
close();
}
PlatformResult UnZip::listEntries(unsigned long *decompressedSize, ArchiveFileEntryPtrMapPtr* out_map)
{
+ LoggerD("Enter");
if(!m_is_open) {
LoggerE("Failed to get list of entries - UnZip closed");
return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to get list of files in zip archive");
PlatformResult UnZip::extractAllFilesTo(const std::string& extract_path,
ExtractAllProgressCallback* callback)
{
+ LoggerD("Enter");
if(!m_is_open) {
LoggerE("Failed to extract files - UnZip closed");
return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to extract zip archive");
unz_global_info gi;
PlatformResult result = updateCallbackWithArchiveStatistics(callback, gi);
if ( result.error_code() != ErrorCode::NO_ERROR) {
+ LoggerE("Error: %s", result.message().c_str());
return result;
}
//
int err = unzGoToFirstFile(m_unzip);
if (err != UNZ_OK) {
- LoggerW("%s",getArchiveLogMessage(err, "unzGoToFirstFile()").c_str());
+ LoggerE("%s",getArchiveLogMessage(err, "unzGoToFirstFile()").c_str());
}
for (uLong i = 0; i < gi.number_entry; i++) {
result = extractCurrentFile(extract_path, std::string(), callback);
if ( result.error_code() != ErrorCode::NO_ERROR) {
+ LoggerE("Fail: extractCurrentFile()");
return result;
}
PlatformResult UnZip::extractTo(ExtractEntryProgressCallback* callback)
{
+ LoggerD("Enter");
if(!m_is_open) {
LoggerE("Extract archive file entry failed - UnZip closed");
return PlatformResult(ErrorCode::UNKNOWN_ERR, "Extract archive file entry failed");
unz_global_info gi;
PlatformResult result = updateCallbackWithArchiveStatistics(callback, gi, entry_name_in_zip);
if ( result.error_code() != ErrorCode::NO_ERROR) {
+ LoggerE("Fail: updateCallbackWithArchiveStatistics()");
return result;
}
unsigned int matched;
result = IterateFilesInZip(gi, entry_name_in_zip, callback, extractItFunction, matched, &h);
if ( result.error_code() != ErrorCode::NO_ERROR) {
+ LoggerE("Fail: IterateFilesInZip()");
return result;
}
PlatformResult UnZip::extractItFunction(const std::string& file_name, unz_file_info& file_info,
void* user_data)
{
+ LoggerD("Enter");
ExtractDataHolder* h = static_cast<ExtractDataHolder*>(user_data);
if(!h) {
LoggerE("ExtractDataHolder is NULL!");
h->callback->getStripBasePath(),
h->callback);
if ( result.error_code() != ErrorCode::NO_ERROR) {
+ LoggerE("Error: %s", result.message().c_str());
return result;
}
unsigned int& num_file_or_folder_matched,
void* user_data)
{
+ LoggerD("Enter");
int err = unzGoToFirstFile(m_unzip);
if (UNZ_OK != err) {
LoggerW("%s",getArchiveLogMessage(err, "unzGoToFirstFile()").c_str());
if(match) {
PlatformResult result = itfunc(cur_filename_in_zip, cur_file_info, user_data);
if ( result.error_code() != ErrorCode::NO_ERROR) {
+ LoggerE("Error: %s", result.message().c_str());
return result;
}
++num_file_or_folder_matched;
PlatformResult generateArchiveStatistics(const std::string& file_name, unz_file_info& file_info,
void* user_data)
{
+ LoggerD("Enter");
if(user_data) {
ArchiveStatistics* astats = static_cast<ArchiveStatistics*>(user_data);
astats->uncompressed_size += file_info.uncompressed_size;
unz_global_info& out_global_info,
const std::string optional_filter)
{
+ LoggerD("Enter");
int err = unzGetGlobalInfo(m_unzip, &out_global_info);
if (UNZ_OK != err) {
LoggerE("ret: %d",err);
PlatformResult result = IterateFilesInZip(out_global_info, optional_filter,
callback, generateArchiveStatistics, num_matched, &astats);
if ( result.error_code() != ErrorCode::NO_ERROR) {
+ LoggerE("Error: %s", result.message().c_str());
return result;
}
if(0 == num_matched) {
const std::string& entry_name_in_zip,
OperationCallbackData* callback,
IterateFunction itfunc,
- unsigned int& num_file_or_folder_matched,
+ unsigned int& num_file_or_folder_matched,
void* user_data);
PlatformResult updateCallbackWithArchiveStatistics(ExtractAllProgressCallback* callback,
FilePathStatus getPathStatus(const std::string& path)
{
+ LoggerD("Enter");
if(path.empty()) {
return FPS_NOT_EXIST;
}
void divideToPathAndName(const std::string& filepath, std::string& out_path,
std::string& out_name)
{
+ LoggerD("Enter");
size_t pos_last_dir = filepath.find_last_of("/\\");
if(pos_last_dir == std::string::npos) {
out_path = "";
void createMissingDirectories(const std::string& path, bool check_first = true)
{
+ LoggerD("Enter");
if(check_first) {
const FilePathStatus path_status = getPathStatus(path);
//LoggerD("[%s] status: %d", path.c_str(), path_status);
void changeFileAccessAndModifyDate(const std::string& filepath, tm_unz tmu_date)
{
+ LoggerD("Enter");
struct utimbuf ut;
struct tm newdate;
newdate.tm_sec = tmu_date.tm_sec;
const std::string& base_strip_path,
BaseProgressCallback* callback)
{
+ LoggerD("Enter");
UnZipExtractRequest req(owner, extract_path, base_strip_path, callback);
if(!req.m_callback){
LoggerE("Callback is null");
m_is_directory_entry(false)
{
+ LoggerD("Enter");
}
PlatformResult UnZipExtractRequest::run()
PlatformResult result = getCurrentFileInfo();
if (result.error_code() != ErrorCode::NO_ERROR) {
+ LoggerE("Error: %s", result.message().c_str());
return result;
}
UnZipExtractRequest::~UnZipExtractRequest()
{
+ LoggerD("Enter");
+
if(m_output_file) {
fclose(m_output_file);
m_output_file = NULL;
filesystem::NodePtr node;
PlatformResult result = filesystem::Node::resolve(path, &node);
if (result.error_code() != ErrorCode::NO_ERROR) {
+ LoggerE("Error: %s", result.message().c_str());
return result;
}
result = node->remove(filesystem::OPT_RECURSIVE);
if (result.error_code() != ErrorCode::NO_ERROR) {
+ LoggerE("Error: %s", result.message().c_str());
return result;
}
}
void Zip::generateZipFileInfo(const std::string& filename, zip_fileinfo& out_zi)
{
+ LoggerD("Enter");
+
memset(&out_zi, 0, sizeof(zip_fileinfo));
time_t tm_t = 0;
Zip::~Zip()
{
+ LoggerD("Enter");
+
close();
}
m_compression_level(0),
m_new_file_in_zip_opened(false)
{
+ LoggerD("Enter");
+
}
ZipAddRequest::~ZipAddRequest()
{
+ LoggerD("Enter");
if(m_input_file) {
fclose(m_input_file);
m_input_file = NULL;
PlatformResult ZipAddRequest::execute(Zip& owner, AddProgressCallback*& callback)
{
+ LoggerD("Enter");
ZipAddRequest req(owner, callback);
return req.run();
}
PlatformResult ZipAddRequest::run()
{
+ LoggerD("Enter");
if(!m_callback) {
LoggerE("m_callback is NULL");
return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not add file(-s) to archive");
void ZipAddRequest::addNodeAndSubdirsToList(filesystem::NodePtr src_node,
filesystem::NodeList& out_list_of_child_nodes)
{
+ LoggerD("Enter");
out_list_of_child_nodes.push_back(src_node);
if(filesystem::NT_DIRECTORY == src_node->getType()) {
PlatformResult ZipAddRequest::addToZipArchive(filesystem::NodePtr src_file_node)
{
+ LoggerD("Enter");
const std::string name_in_zip = getNameInZipArchiveFor(src_file_node,
m_callback->getFileEntry()->getStriped());
const std::string src_file_path = src_file_node->getPath()->getFullPath();
std::string removeDirCharsFromFront(const std::string& path)
{
+ LoggerD("Enter");
for(size_t i = 0; i < path.length(); ++i) {
const char& cur = path[i];
if(cur != '/' && cur != '\\') {
std::string generateFullPathForZip(const std::string& path)
{
+ LoggerD("Enter");
//Step 1: Remove / from begining
const size_t path_len = path.length();
std::string ZipAddRequest::getNameInZipArchiveFor(filesystem::NodePtr node, bool strip)
{
+ LoggerD("Enter");
const std::string node_full_path = node->getPath()->getFullPath();
std::string cut_path;