summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@redhat.com>2024-01-19 18:47:23 +0100
committerTomas Bzatek <tbzatek@redhat.com>2024-01-19 18:47:23 +0100
commit9d1ee3294040a5befb7d16cbbd6f1e8c781f6353 (patch)
tree974ed7b72e32205684043710e2cbb56312915eae
parent22f9564566e5a6577be9bbd3e4297fb761d2e2d1 (diff)
downloadtuxcmd-modules-9d1ee3294040a5befb7d16cbbd6f1e8c781f6353.tar.xz
zip: Use the new common logging macros
-rw-r--r--zip/Makefile5
l---------zip/logutils.c1
l---------zip/logutils.h1
-rw-r--r--zip/zip.cpp431
4 files changed, 211 insertions, 227 deletions
diff --git a/zip/Makefile b/zip/Makefile
index e4a8b71..d5981ed 100644
--- a/zip/Makefile
+++ b/zip/Makefile
@@ -10,12 +10,12 @@ CPP = g++
CFLAGS = -I. -I$(DIR_ZIPARCHIVE) -I/usr/include \
-Wall -Wtype-limits -Wno-unknown-pragmas -fPIC -O2 -g -ggdb \
-DG_DISABLE_DEPRECATED -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE \
- -D__VERBOSE_DEBUGx
+ -D__DEBUG_INTERNALx -D_LOG_DOMAIN="zip"
LIB_SUFFIX = `if test \`uname -m\` = x86_64 -o \`uname -m\` = ppc64; then echo 64; fi`
-VFS_COMMON_OBJECTS = filelist.o filelist-vfs-intf.o strutils.o vfsutils.o
+VFS_COMMON_OBJECTS = filelist.o filelist-vfs-intf.o strutils.o vfsutils.o logutils.o
VFS_C_OBJECTS =
VFS_CPP_OBJECTS = zip.o
@@ -40,6 +40,7 @@ filelist.o: filelist.h filelist.c
filelist-vfs-intf.o: filelist-vfs-intf.h filelist-vfs-intf.c
strutils.o: strutils.h strutils.c
vfsutils.o: vfsutils.h vfsutils.c
+logutils.o: logutils.h logutils.c
install::
diff --git a/zip/logutils.c b/zip/logutils.c
new file mode 120000
index 0000000..c1e4fc5
--- /dev/null
+++ b/zip/logutils.c
@@ -0,0 +1 @@
+../common/logutils.c \ No newline at end of file
diff --git a/zip/logutils.h b/zip/logutils.h
new file mode 120000
index 0000000..ed79bd9
--- /dev/null
+++ b/zip/logutils.h
@@ -0,0 +1 @@
+../common/logutils.h \ No newline at end of file
diff --git a/zip/zip.cpp b/zip/zip.cpp
index c0ccd99..b33cf2d 100644
--- a/zip/zip.cpp
+++ b/zip/zip.cpp
@@ -1,6 +1,6 @@
/* ZIP plugin for Tux Commander
- * version 0.7, designed for ZipArchive v4.6.9
- * Copyright (C) 2004-2023 Tomas Bzatek <tbzatek@users.sourceforge.net>
+ * version 0.7.1, designed for ZipArchive v4.6.9
+ * Copyright (C) 2004-2024 Tomas Bzatek <tbzatek@users.sourceforge.net>
* Check for updates on tuxcmd.sourceforge.net
*
* Uses ZipArchive library
@@ -39,6 +39,7 @@
#include "tuxcmd-vfs.h"
#include "strutils.h"
#include "vfsutils.h"
+#include "logutils.h"
#include "filelist.h"
#include "filelist-vfs-intf.h"
@@ -48,8 +49,8 @@
-#define VERSION "0.7"
-#define BUILD_DATE "2023-12-17"
+#define VERSION "0.7.1"
+#define BUILD_DATE "2024-01-19"
#define DEFAULT_BLOCK_SIZE 65536
@@ -62,13 +63,13 @@ extern "C" {
/** Utilities */
/************** ****************/
-static void
+static void
zip_error_to_gerror (CZipException e, GError **error)
{
gint code;
-
+
switch (e.m_iCause) {
- case CZipException::noError: // No error.
+ case CZipException::noError: // No error.
code = G_IO_ERROR_UNKNOWN;
break;
case CZipException::genericError: // An unknown error.
@@ -170,72 +171,71 @@ struct TVFSGlobs {
void *callback_data;
};
+
+
// Define the progress class and the class methods
struct ZIP_API CVFSZipActionCallback : public CZipActionCallback
{
- CVFSZipActionCallback()
- {
- m_uTotalToProcess = 0;
- m_uProcessed = 0;
- globs = NULL;
- }
+ struct TVFSGlobs *globs;
- struct TVFSGlobs *globs;
-
- virtual bool Callback(ZIP_SIZE_TYPE uProgress)
- {
- fprintf (stderr, "(II) Callback called, position = %" G_GUINT32_FORMAT "; m_uTotalToProcess = %" G_GUINT32_FORMAT "; m_uProcessed = %" G_GUINT32_FORMAT "\n",
- uProgress, m_uTotalToProcess, m_uProcessed);
- bool ret = true;
- try {
- if (globs && globs->callback_progress)
- ret = globs->callback_progress (m_uProcessed, NULL, globs->callback_data);
- }
- catch (...) {
- fprintf (stderr, "(EE) extract_callback: Fatal error occured when calling pCallBackProgress\n");
- }
- return ret;
- }
-};
+ virtual bool Callback(ZIP_SIZE_TYPE uProgress) {
+ bool ret = true;
+
+ log_info ("extract_callback: position = %" G_GUINT32_FORMAT "; m_uTotalToProcess = %" G_GUINT32_FORMAT "; m_uProcessed = %" G_GUINT32_FORMAT,
+ uProgress, m_uTotalToProcess, m_uProcessed);
+ try {
+ if (globs && globs->callback_progress)
+ ret = globs->callback_progress (m_uProcessed, NULL, globs->callback_data);
+ } catch (...) {
+ log_error ("extract_callback: Fatal error occured when calling pCallBackProgress\n");
+ }
+ return ret;
+ }
+ CVFSZipActionCallback() {
+ m_uTotalToProcess = 0;
+ m_uProcessed = 0;
+ globs = NULL;
+ }
+};
/***********************************************************************************************************************
* Internal tree functions
********/
-static void
+static void
build_global_filelist (struct TVFSGlobs *globs)
{
unsigned long int iCount;
unsigned long int i;
CZipFileHeader *fh;
- struct TVFSItem *item;
char *s;
-
+
/* Ensure the filelist is freed */
- if (globs->vfs_filelist)
- vfs_filelist_free (globs->vfs_filelist);
- if (globs->files)
- filelist_tree_free (globs->files);
-
- globs->files = filelist_tree_new();
+ if (globs->vfs_filelist)
+ vfs_filelist_free (globs->vfs_filelist);
+ if (globs->files)
+ filelist_tree_free (globs->files);
+
+ globs->files = filelist_tree_new ();
globs->vfs_filelist = vfs_filelist_new (globs->files);
- iCount = globs->zip->GetCount();
+ iCount = globs->zip->GetCount ();
/* list files in the archive */
for (i = 0; i < iCount; i++) {
fh = globs->zip->GetFileInfo (i);
- if (fh != NULL)
- printf(" No: %lu, '%s', IsDir: %i, Size: %" G_GUINT32_FORMAT ", SystemAttr = 0x%" G_GINT32_MODIFIER "X, OriginalAttr = 0x%" G_GINT32_MODIFIER "X, encrypted = %d\n",
- i, (LPCTSTR)fh->GetFileName(), fh->IsDirectory(), fh->m_uUncomprSize, fh->GetSystemAttr(), fh->GetOriginalAttributes(), fh->IsEncrypted());
- }
- printf("\n\n");
-
+ if (fh != NULL && _log_level >= LOG_INFO)
+ g_print (" [%lu] '%s', IsDir: %i, Size: %" G_GUINT32_FORMAT ", SystemAttr = 0x%" G_GINT32_MODIFIER "X, OriginalAttr = 0x%" G_GINT32_MODIFIER "X, encrypted = %d\n",
+ i, (LPCTSTR)fh->GetFileName(), fh->IsDirectory(), fh->m_uUncomprSize, fh->GetSystemAttr(), fh->GetOriginalAttributes(), fh->IsEncrypted());
+ }
+
for (i = 0; i < iCount; i++) {
fh = globs->zip->GetFileInfo (i);
if (fh != NULL) {
+ struct TVFSItem *item;
+
/* Create a TVFSItem entry and fill all info */
item = (struct TVFSItem *) g_malloc0 (sizeof (struct TVFSItem));
@@ -252,22 +252,20 @@ build_global_filelist (struct TVFSGlobs *globs)
item->m_time = (__time_t) fh->GetModificationTime ();
item->c_time = (__time_t) fh->GetCreationTime ();
item->a_time = (__time_t) fh->GetLastAccessTime ();
-
+
if (fh->IsEncrypted ())
globs->need_password = TRUE;
-
- /* Add item to the global list and continue with next file */
+
+ /* Add item to the global list and continue with next file */
s = g_filename_display_name ((LPCTSTR) fh->GetFileName ());
filelist_tree_add_item (globs->files, s, item, (LPCTSTR) fh->GetFileName (), i + 1);
g_free (s);
- printf ("\n");
}
}
if (globs->need_password)
- printf ("Password present.\n");
+ log_notice ("Password present.");
- printf ("\n\n\n\nPrinting the contents of the global filelist:\n\n");
filelist_tree_print (globs->files);
}
@@ -280,21 +278,12 @@ VFSNew (TVFSLogFunc log_func)
{
struct TVFSGlobs * globs;
+ log_init ();
+
globs = (struct TVFSGlobs *) g_malloc0 (sizeof (struct TVFSGlobs));
- globs->archive_opened = FALSE;
globs->block_size = DEFAULT_BLOCK_SIZE;
- globs->archive_modified = FALSE;
- globs->need_password = FALSE;
-
- globs->callback_data = NULL;
- globs->callback_ask_question = NULL;
- globs->callback_ask_password = NULL;
- globs->callback_progress = NULL;
-
globs->log_func = log_func;
- if (globs->log_func != NULL)
- globs->log_func ("zip plugin: VFSInit");
return globs;
}
@@ -317,8 +306,10 @@ VFSSetCallbacks (struct TVFSGlobs *globs,
void
VFSFree (struct TVFSGlobs *globs)
{
- if (globs->log_func != NULL)
- globs->log_func ("zip plugin: VFSFree");
+ g_free (globs->curr_dir);
+ g_free (globs->archive_path);
+ vfs_filelist_free (globs->vfs_filelist);
+ filelist_tree_free (globs->files);
g_free (globs);
}
@@ -334,13 +325,13 @@ struct TVFSInfo *
VFSGetInfo ()
{
struct TVFSInfo *module_info;
-
+
module_info = (TVFSInfo*) g_malloc0 (sizeof (struct TVFSInfo));
module_info->ID = g_strdup ("zip_plugin");
module_info->Name = g_strdup ("ZIP plugin");
module_info->About = g_strdup_printf ("version %s, build date: %s\nusing ZipArchive library v%s\n", VERSION, BUILD_DATE, CZipArchive::m_gszVersion);
- module_info->Copyright = g_strdup_printf ("Plugin Copyright (C) 2004-2023 Tomáš Bžatek\n%s", CZipArchive::m_gszCopyright);
+ module_info->Copyright = g_strdup_printf ("Plugin Copyright (C) 2004-2024 Tomáš Bžatek\n%s", CZipArchive::m_gszCopyright);
return module_info;
}
@@ -363,45 +354,40 @@ VFSGetArchiveExts ()
/**************************************************************************************************************************************/
/**************************************************************************************************************************************/
-gboolean
+gboolean
VFSOpenArchive (struct TVFSGlobs *globs, const char *sName, GError **error)
{
int iCount;
-
- globs->files = NULL;
- globs->vfs_filelist = NULL;
-
- globs->curr_dir = NULL;
+
+ log_notice ("VFSOpenArchive: opening archive '%s':", sName);
globs->zip = new CZipArchive;
try {
- fprintf (stderr, "(--) VFSOpenArchive: trying to open the file...\n");
-
try {
if (! globs->zip->Open (sName, CZipArchive::zipOpen, 0)) {
- printf ("(EE) VFSOpenArchive: error opening zip archive\n");
+ log_error ("VFSOpenArchive: error opening zip archive");
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Error opening zip archive.");
return FALSE;
}
}
catch (...) {
- printf ("(!!) VFSOpenArchive: error opening readwrite zip, trying readonly...\n");
+ log_notice ("VFSOpenArchive: error opening readwrite zip, trying readonly...");
try {
/* try to open in read only mode (required if there's no write access on the media) */
if (! globs->zip->Open (sName, CZipArchive::zipOpenReadOnly, 0)) {
- printf ("(EE) VFSOpenArchive: error opening readonly zip archive\n");
+ log_error ("VFSOpenArchive: error opening readonly zip archive");
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Error opening readonly zip archive.");
return FALSE;
}
}
catch (CZipException& e) {
- printf ("(EE) VFSOpenArchive: error opening readonly zip\n");
+ log_error ("VFSOpenArchive: error opening readonly zip archive");
zip_error_to_gerror (e, error);
return FALSE;
}
}
iCount = globs->zip->GetCount (false);
- printf ("(II) VFSOpenArchive: %i records found, %i files.\n", iCount, globs->zip->GetCount (true));
+ log_info ("VFSOpenArchive: %i records found, %i files.", iCount, globs->zip->GetCount (true));
if (iCount < 1) {
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "No files found in the archive.");
return FALSE;
@@ -420,34 +406,33 @@ VFSOpenArchive (struct TVFSGlobs *globs, const char *sName, GError **error)
globs->zip->SetAutoFinalize (true);
}
catch (CZipException& e) {
- printf ("(EE) VFSOpenArchive: Error while processing archive %s\n%s\n", (LPCTSTR) sName, (LPCTSTR)e.GetErrorDescription());
- if (e.m_szFileName.IsEmpty())
- printf ("\n");
- else
- printf ("(EE) VFSOpenArchive: Filename in error object: %s\n\n", (LPCTSTR)e.m_szFileName);
+ log_error ("VFSOpenArchive: Error while processing archive %s: %s", sName, (LPCTSTR)e.GetErrorDescription());
+ if (! e.m_szFileName.IsEmpty())
+ log_notice ("VFSOpenArchive: Filename in error object: %s", (LPCTSTR)e.m_szFileName);
globs->zip->Close (true);
zip_error_to_gerror (e, error);
return FALSE;
}
catch (...) {
- printf ("(EE) VFSOpenArchive: Unknown error while processing archive %s\n\n", (LPCTSTR) sName);
+ log_error ("VFSOpenArchive: Unknown error while processing archive %s", sName);
globs->zip->Close (true);
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Unknown error while processing zip archive.");
return FALSE;
}
+ log_info ("VFSOpenArchive: done.");
globs->archive_path = g_strdup (sName);
globs->archive_modified = FALSE;
return TRUE;
}
-gboolean
+gboolean
VFSClose (struct TVFSGlobs *globs, GError **error)
{
if (globs) {
- /* close the archive... */
- fprintf (stderr, "(II) VFSClose: Closing the archive...\n");
+ /* flush and close the archive... */
+ log_notice ("VFSClose: Closing the archive...");
try {
if (globs->archive_modified)
globs->zip->FlushBuffers ();
@@ -458,32 +443,35 @@ VFSClose (struct TVFSGlobs *globs, GError **error)
globs->zip->Close (CZipArchive::afNoException, false);
}
catch (CZipException& e) {
- fprintf (stderr, "(EE) VFSClose: Error while closing archive: %s\n", (LPCTSTR)e.GetErrorDescription());
+ log_error ("VFSClose: Error while closing archive: %s", (LPCTSTR)e.GetErrorDescription());
zip_error_to_gerror (e, error);
return FALSE;
}
/* free the ZIP objects... */
- fprintf (stderr, "(II) VFSClose: Freeing ZipArchive objects...\n");
+ log_debug ("VFSClose: Freeing ZipArchive objects...");
try {
delete globs->extract_callback;
delete globs->zip;
}
catch (...) {
- fprintf (stderr, "(EE) VFSClose: Error freeing ZipArchive objects\n");
+ log_error ("VFSClose: Error freeing ZipArchive objects");
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Error freeing ZipArchive objects.");
return FALSE;
}
/* free the filelist */
- fprintf (stderr, "(II) VFSClose: Freeing filelist...\n");
- if (globs->vfs_filelist)
- vfs_filelist_free (globs->vfs_filelist);
- if (globs->files)
- filelist_tree_free (globs->files);
+ log_debug ("VFSClose: Freeing filelist...");
+ vfs_filelist_free (globs->vfs_filelist);
+ globs->vfs_filelist = NULL;
+ filelist_tree_free (globs->files);
+ globs->files = NULL;
/* free the rest... */
g_free (globs->archive_path);
+ globs->archive_path = NULL;
+ g_free (globs->curr_dir);
+ globs->curr_dir = NULL;
}
return TRUE;
}
@@ -508,11 +496,11 @@ VFSGetFileSystemInfo (struct TVFSGlobs *globs, const char *APath, gint64 *FSSize
/******************************************************************************************************/
-gboolean
+gboolean
VFSChangeDir (struct TVFSGlobs *globs, const char *NewPath, GError **error)
{
char *s;
-
+
s = vfs_filelist_change_dir (globs->vfs_filelist, NewPath, error);
if (s) {
globs->curr_dir = s;
@@ -525,7 +513,7 @@ VFSChangeDir (struct TVFSGlobs *globs, const char *NewPath, GError **error)
gboolean
VFSGetPasswordRequired (struct TVFSGlobs *globs)
{
- if (globs)
+ if (globs)
return globs->need_password;
return FALSE;
}
@@ -543,7 +531,7 @@ VFSResetPassword (struct TVFSGlobs *globs)
struct TVFSItem *
VFSListFirst (struct TVFSGlobs *globs, const char *sDir, gboolean FollowSymlinks, gboolean AddFullPath, GError **error)
{
- printf ("(--) VFSListFirst: Going to list all items in '%s'\n", sDir);
+ log_debug ("VFSListFirst: Going to list all items in '%s'", sDir);
return vfs_filelist_list_first (globs->vfs_filelist, sDir, FollowSymlinks, AddFullPath, error);
}
@@ -566,7 +554,7 @@ VFSListClose (struct TVFSGlobs *globs, GError **error)
struct TVFSItem *
VFSFileInfo (struct TVFSGlobs *globs, const char *AFileName, gboolean FollowSymlinks, gboolean AddFullPath, GError **error)
{
- printf ("(--) VFSFileInfo: requested info for object '%s'\n", AFileName);
+ log_debug ("VFSFileInfo: requested info for object '%s'", AFileName);
return vfs_filelist_file_info (globs->vfs_filelist, AFileName, FollowSymlinks, AddFullPath, error);
}
@@ -575,7 +563,7 @@ VFSFileInfo (struct TVFSGlobs *globs, const char *AFileName, gboolean FollowSyml
/** Recursive tree size counting */
/************** ****************/
-guint64
+guint64
VFSGetDirSize (struct TVFSGlobs *globs, const char *APath)
{
if (! globs)
@@ -583,11 +571,11 @@ VFSGetDirSize (struct TVFSGlobs *globs, const char *APath)
return vfs_filelist_get_dir_size (globs->vfs_filelist, APath);
}
-void
+void
VFSBreakGetDirSize (struct TVFSGlobs *globs)
{
- printf ("(WW) VFSBreakGetDirSize: calling break\n");
- if (globs)
+ log_debug ("VFSBreakGetDirSize: calling break");
+ if (globs)
vfs_filelist_get_dir_size_break (globs->vfs_filelist);
}
@@ -604,68 +592,66 @@ VFSMkDir (struct TVFSGlobs *globs, const char *sDirName, GError **error)
bool bRet;
if (sDirName == NULL || strlen (sDirName) < 1) {
- printf ("(EE) VFSMkDir: The value of 'sDirName' is NULL or empty\n");
+ log_error ("VFSMkDir: The value of 'sDirName' is NULL or empty");
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT, "The value of 'sDirName' is NULL or empty.");
return FALSE;
}
if (strcmp (sDirName, "/") == 0) {
- printf ("(EE) VFSMkDir: Invalid value '%s' (duplicate the root entry?)\n", sDirName);
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT, "Invalid value '%s' (duplicate the root entry?)", sDirName);
+ log_error ("VFSMkDir: Invalid value '%s' (duplicate root entry?)", sDirName);
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT, "Invalid value '%s' (duplicate root entry)", sDirName);
return FALSE;
}
- printf ("(II) VFSMkDir: Going to create new directory '%s'...\n", sDirName);
+ log_notice ("VFSMkDir: Creating new directory '%s'", sDirName);
try {
try {
- header.SetSystemAttr(ZipPlatform::GetDefaultDirAttributes());
+ header.SetSystemAttr (ZipPlatform::GetDefaultDirAttributes());
s = exclude_leading_path_sep (sDirName);
- header.SetFileName(s);
+ header.SetFileName (s);
g_free (s);
header.SetCreationTime (time (NULL));
header.SetModificationTime (time (NULL));
bRet = globs->zip->OpenNewFile (header, 0, NULL);
globs->zip->CloseNewFile ();
if (! bRet) {
- printf ("(EE) VFSMkDir: Error creating new directory '%s'\n", sDirName);
+ log_error ("VFSMkDir: Error creating new directory '%s'", sDirName);
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Error creating new directory.");
return FALSE;
- }
- globs->archive_modified = TRUE;
+ }
+ globs->archive_modified = TRUE;
build_global_filelist (globs);
return TRUE;
}
catch (CZipException& e) {
globs->zip->CloseNewFile (true);
- fprintf (stderr, "(EE) VFSMkDir: Error creating new directory '%s': [%d] %s, archive closed = %d.\n",
- sDirName, e.m_iCause, (LPCTSTR)e.GetErrorDescription(), globs->zip->IsClosed ());
+ log_error ("VFSMkDir: Error creating new directory '%s': [%d] %s, archive closed = %d",
+ sDirName, e.m_iCause, (LPCTSTR)e.GetErrorDescription(), globs->zip->IsClosed ());
zip_error_to_gerror (e, error);
return FALSE;
}
}
catch (...)
{
- printf ("(EE) VFSMkDir: Error creating new directory '%s'\n", sDirName);
+ log_error ("VFSMkDir: Error creating new directory '%s'", sDirName);
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Error creating new directory.");
return FALSE;
}
}
-gboolean
+gboolean
VFSRemove (struct TVFSGlobs *globs, const char *APath, GError **error)
{
char *AFile, *AFile1, *AFile2, *AFile3;
long int file_no;
-
-
- printf ("(II) VFSRemove: Going to remove the file '%s'...\n", APath);
+
+ log_notice ("VFSRemove: Removing file '%s'...", APath);
AFile = exclude_trailing_path_sep (APath);
file_no = filelist_find_original_index_by_path (globs->files, AFile) - 1;
g_free (AFile);
-
if (file_no < 0) {
- printf ("(EE) VFSRemove: can't find the file specified: '%s'\n", APath);
+ log_error ("VFSRemove: can't find the file specified: '%s'", APath);
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "Can't find the file specified.");
return FALSE;
}
@@ -673,14 +659,14 @@ VFSRemove (struct TVFSGlobs *globs, const char *APath, GError **error)
try {
try {
if (! globs->zip->RemoveFile (file_no)) {
- printf ("(EE) VFSRemove: Delete file '%s' failed.\n", APath);
+ log_error ("VFSRemove: Delete file '%s' failed.", APath);
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Delete file '%s' failed.", APath);
return FALSE;
}
build_global_filelist (globs);
globs->archive_modified = TRUE;
- printf ("(II) VFSRemove OK.\n");
-
+ log_debug ("VFSRemove OK.");
+
/* If we delete last file from a directory, we should make an empty one.
* Some archives store pathnames only with filenames, no separate records for directories.
**/
@@ -688,30 +674,30 @@ VFSRemove (struct TVFSGlobs *globs, const char *APath, GError **error)
AFile2 = g_path_get_dirname (AFile1);
AFile3 = exclude_trailing_path_sep (AFile2);
if (strlen (AFile3) > 0 && g_strcmp0 (AFile3, "/") != 0) {
- printf ("(II) VFSRemove: AFile1: '%s', AFile2: '%s', AFile3: '%s'\n", AFile1, AFile2, AFile3);
+ log_debug ("VFSRemove: AFile1: '%s', AFile2: '%s', AFile3: '%s'", AFile1, AFile2, AFile3);
file_no = filelist_find_original_index_by_path (globs->files, AFile2) - 1;
- printf ("(II) VFSRemove: deleted: '%s', parent: '%s', file_no = %ld\n", APath, AFile3, file_no);
+ log_debug ("VFSRemove: deleted: '%s', parent: '%s', file_no = %ld", APath, AFile3, file_no);
if (file_no < 0) {
- printf ("(WW) VFSRemove: sparse ZIP archive detected, adding empty directory: '%s'\n", AFile3);
+ log_notice ("VFSRemove: sparse ZIP archive detected, adding an empty directory: '%s'", AFile3);
VFSMkDir (globs, AFile3, NULL);
}
- }
- g_free (AFile1);
- g_free (AFile2);
+ }
+ g_free (AFile1);
+ g_free (AFile2);
g_free (AFile3);
-
+
return TRUE;
}
catch (CZipException& e) {
- fprintf (stderr, "(EE) VFSRemove: Delete file '%s' failed: [%d] %s, archive closed = %d.\n",
- APath, e.m_iCause, (LPCTSTR)e.GetErrorDescription(), globs->zip->IsClosed ());
+ log_error ("VFSRemove: Delete file '%s' failed: [%d] %s, archive closed = %d",
+ APath, e.m_iCause, (LPCTSTR)e.GetErrorDescription(), globs->zip->IsClosed ());
zip_error_to_gerror (e, error);
return FALSE;
}
}
catch (...)
{
- printf ("(EE) VFSRemove: Delete file '%s' failed.\n", APath);
+ log_error ("VFSRemove: Delete file '%s' failed.", APath);
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Delete file '%s' failed.", APath);
return FALSE;
}
@@ -727,7 +713,7 @@ VFSRename (struct TVFSGlobs *globs, const char *sSrcName, const char *sDstName,
long int file_no;
CZipFileHeader *fh;
- printf ("(II) VFSRename: Going to rename/move the file '%s' to '%s'...\n", sSrcName, sDstName);
+ log_notice ("VFSRename: Renaming/moving file '%s' to '%s'...", sSrcName, sDstName);
AFile = exclude_trailing_path_sep (sSrcName);
s = exclude_trailing_path_sep (sDstName);
@@ -737,7 +723,7 @@ VFSRename (struct TVFSGlobs *globs, const char *sSrcName, const char *sDstName,
g_free (AFile);
if (file_no < 0) {
- printf ("(EE) VFSRename: can't find the file specified: '%s'\n", sSrcName);
+ log_error ("VFSRename: can't find the file specified: '%s'", sSrcName);
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "Can't find the file specified.");
return FALSE;
}
@@ -746,60 +732,60 @@ VFSRename (struct TVFSGlobs *globs, const char *sSrcName, const char *sDstName,
try {
fh = globs->zip->GetFileInfo (file_no);
if (fh == NULL) {
- printf ("(EE) VFSRename: can't find the file specified: '%s'\n", sSrcName);
+ log_error ("VFSRename: can't find the file specified: '%s'", sSrcName);
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "Can't find the file specified.");
return FALSE;
}
if (! fh->SetFileName (ADestFile)) {
- printf ("(EE) VFSRename: Rename/move file '%s' failed.\n", sSrcName);
+ log_error ("VFSRename: Rename/move file '%s' failed.", sSrcName);
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Rename/move file '%s' failed.", sSrcName);
return FALSE;
}
g_free (ADestFile);
build_global_filelist (globs);
- globs->archive_modified = TRUE;
+ globs->archive_modified = TRUE;
return TRUE;
}
catch (CZipException& e) {
- fprintf (stderr, "(EE) VFSRename: Rename/move file '%s' failed: [%d] %s, archive closed = %d.\n",
- sSrcName, e.m_iCause, (LPCTSTR)e.GetErrorDescription(), globs->zip->IsClosed ());
+ log_error ("VFSRename: Rename/move file '%s' failed: [%d] %s, archive closed = %d.",
+ sSrcName, e.m_iCause, (LPCTSTR)e.GetErrorDescription(), globs->zip->IsClosed ());
zip_error_to_gerror (e, error);
return FALSE;
}
}
catch (...)
{
- printf ("(EE) VFSRename: Rename/move file failed.\n");
+ log_error ("VFSRename: Rename/move file failed.");
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Rename/move file failed.");
return FALSE;
}
}
-gboolean
+gboolean
VFSMakeSymLink (struct TVFSGlobs *globs, const char *NewFileName, const char *PointTo, GError **error)
{
- fprintf (stderr, "(EE) VFSMakeSymLink: Symbolic links not supported in ZIP archives.\n");
+ log_error ("VFSMakeSymLink: Symbolic links not supported in ZIP archives.");
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "Symbolic links not supported in ZIP archives.");
return FALSE;
}
-gboolean
+gboolean
VFSChmod (struct TVFSGlobs *globs, const char *FileName, guint32 Mode, GError **error)
{
char *AFile;
long int file_no;
CZipFileHeader *header;
- printf ("(II) VFSChmod: Going to change permissions of the file '%s'...\n", FileName);
+ log_notice ("VFSChmod: Changing permissions of '%s' to %u...", FileName, Mode);
AFile = exclude_trailing_path_sep (FileName);
file_no = filelist_find_original_index_by_path (globs->files, AFile) - 1;
g_free (AFile);
if (file_no < 0) {
- printf ("(EE) VFSChmod: can't find the file specified: '%s'\n", FileName);
+ log_error ("VFSChmod: can't find the file specified: '%s'", FileName);
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "Can't find the file specified.");
return FALSE;
}
@@ -808,34 +794,31 @@ VFSChmod (struct TVFSGlobs *globs, const char *FileName, guint32 Mode, GError **
try {
/* set system compatibility first */
if (! globs->zip->SetSystemCompatibility (ZipCompatibility::zcUnix)) {
- printf ("(EE) VFSChmod: Unable to set system compatibility\n");
+ log_warn ("VFSChmod: Unable to set system compatibility of the ZIP archive to Unix");
}
-
+
/* change the header data */
globs->zip->ReadLocalHeader (file_no);
header = globs->zip->GetFileInfo (file_no);
if (! header) {
- printf ("(EE) VFSChmod: Permissions modification of the file '%s' failed: NULL returned by GetFileInfo()\n", FileName);
+ log_error ("VFSChmod: Permissions modification of the file '%s' failed: NULL returned by GetFileInfo()", FileName);
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Permissions modification of the file '%s' failed: NULL returned by GetFileInfo()", FileName);
return FALSE;
}
- // We need to change only 0xF000FFFF mask
- // The 0xF_______ bits represents file/directory type, the 0x____FFFF represents ZIP attributes and 0x_FFF____ represents unix permissions
-// printf("(II) VFSChmod: Current permissions: %lX, stripped: %lX, setting to: %X, modified: %lX\n",
-// header->GetSystemAttr(), header->GetSystemAttr() & 0xF000FFFF, Mode & 0xFFF, (header->GetSystemAttr() & 0xF000FFFF) + ((Mode & 0xFFF) << 16));
-// globs->zip->SetFileHeaderAttr(*header, (header->GetSystemAttr() & 0xF000FFFF) + ((Mode & 0xFFF) << 16));
-
- printf ("(II) VFSChmod: Current permissions: 0x%" G_GINT32_MODIFIER "X, stripped: 0x%" G_GINT32_MODIFIER "X, setting to: 0x%X, modified: 0x%" G_GINT32_MODIFIER "X\n",
- header->GetSystemAttr(), header->GetSystemAttr() & 0xFFFFF000,
- Mode & 0xFFF, (header->GetSystemAttr() & 0xFFFFF000) + (Mode & 0xFFF));
+ /* Need to change only 0xF000FFFF mask.
+ * The 0xF_______ bits represents file/directory type, the 0x____FFFF represents ZIP attributes and 0x_FFF____ represents unix permissions.
+ */
+ log_debug ("VFSChmod: Current permissions: 0x%" G_GINT32_MODIFIER "X, stripped: 0x%" G_GINT32_MODIFIER "X, setting to: 0x%X, modified: 0x%" G_GINT32_MODIFIER "X",
+ header->GetSystemAttr(), header->GetSystemAttr() & 0xFFFFF000,
+ Mode & 0xFFF, (header->GetSystemAttr() & 0xFFFFF000) + (Mode & 0xFFF));
header->SetSystemAttr ((header->GetSystemAttr() & 0xFFFFF000) + (Mode & 0xFFF));
// globs->zip->SetFileHeaderAttr (*header, (header->GetSystemAttr() & 0xFFFFF000) + (Mode & 0xFFF));
/* write local header information */
globs->zip->OverwriteLocalHeader (file_no);
-#if 0
+#if 0
// Re-encrypt the file
if (header->IsEncrypted()) {
printf("(II) VFSChmod: Re-encrypting the file...\n");
@@ -846,52 +829,52 @@ VFSChmod (struct TVFSGlobs *globs, const char *FileName, guint32 Mode, GError **
globs->zip->RemoveCentralDirectoryFromArchive ();
globs->zip->FlushBuffers ();
- printf ("(II) VFSChmod OK.\n");
- build_global_filelist (globs);
+ log_debug ("VFSChmod OK.");
+ build_global_filelist (globs);
globs->archive_modified = TRUE;
return TRUE;
}
catch (CZipException& e) {
globs->zip->CloseNewFile (true);
- fprintf (stderr, "(EE) VFSChmod: permissions modification of the file '%s' failed: [%d] %s, archive closed = %d.\n",
- FileName, e.m_iCause, (LPCTSTR)e.GetErrorDescription(), globs->zip->IsClosed());
+ log_error ("VFSChmod: permissions modification of the file '%s' failed: [%d] %s, archive closed = %d.",
+ FileName, e.m_iCause, (LPCTSTR)e.GetErrorDescription(), globs->zip->IsClosed());
zip_error_to_gerror (e, error);
return FALSE;
}
}
catch (...)
{
- printf ("(EE) VFSChmod: permissions modification of the file '%s' failed.\n", FileName);
+ log_error ("VFSChmod: permissions modification of the file '%s' failed.", FileName);
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Permissions modification of the file '%s' failed.", FileName);
return FALSE;
}
}
-gboolean
+gboolean
VFSChown (struct TVFSGlobs *globs, const char *FileName, guint32 UID, guint32 GID, GError **error)
{
- fprintf (stderr, "(EE) VFSChown: Owner changing is not supported in ZIP archives.\n");
+ log_error ("VFSChown: Owner changing is not supported in ZIP archives.");
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "Owner changing is not supported in ZIP archives.");
return FALSE;
}
-gboolean
+gboolean
VFSChangeTimes (struct TVFSGlobs *globs, const char *APath, guint32 mtime, guint32 atime, GError **error)
{
char *AFile;
long int file_no;
CZipFileHeader *header;
- printf ("(II) VFSChangeTimes: Going to change date/times of the file '%s'...\n", APath);
+ log_notice ("VFSChangeTimes: Changing date/times of the file '%s'...", APath);
AFile = exclude_trailing_path_sep (APath);
file_no = filelist_find_original_index_by_path (globs->files, AFile) - 1;
g_free (AFile);
if (file_no < 0) {
- printf ("(EE) VFSChangeTimes: can't find the file specified: '%s'\n", APath);
+ log_error ("VFSChangeTimes: can't find the file specified: '%s'", APath);
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "Can't find the file specified.");
return FALSE;
}
@@ -902,7 +885,7 @@ VFSChangeTimes (struct TVFSGlobs *globs, const char *APath, guint32 mtime, guint
globs->zip->ReadLocalHeader (file_no);
header = globs->zip->GetFileInfo (file_no);
if (! header) {
- printf ("(EE) VFSChangeTimes: DateTime modification of the file '%s' failed: NULL returned by GetFileInfo()\n", APath);
+ log_error ("VFSChangeTimes: DateTime modification of the file '%s' failed: NULL returned by GetFileInfo()", APath);
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "DateTime modification of the file '%s' failed: NULL returned by GetFileInfo()", APath);
return FALSE;
}
@@ -918,24 +901,24 @@ VFSChangeTimes (struct TVFSGlobs *globs, const char *APath, guint32 mtime, guint
}
*/
/* write local header information */
- globs->zip->OverwriteLocalHeader (file_no);
+ globs->zip->OverwriteLocalHeader (file_no);
globs->zip->RemoveCentralDirectoryFromArchive ();
-
- printf ("(II) VFSChangeTimes OK.\n");
+
+ log_debug ("VFSChangeTimes OK.");
build_global_filelist (globs);
globs->archive_modified = TRUE;
return TRUE;
}
catch (CZipException& e) {
globs->zip->CloseNewFile (true);
- fprintf (stderr, "(EE) VFSChangeTimes: DateTime modification of the file '%s' failed: [%d] %s, archive closed = %d.\n",
- APath, e.m_iCause, (LPCTSTR)e.GetErrorDescription (), globs->zip->IsClosed ());
+ log_error ("VFSChangeTimes: DateTime modification of the file '%s' failed: [%d] %s, archive closed = %d.",
+ APath, e.m_iCause, (LPCTSTR)e.GetErrorDescription (), globs->zip->IsClosed ());
zip_error_to_gerror (e, error);
return FALSE;
}
}
catch (...) {
- printf ("(EE) VFSChangeTimes: DateTime modification of the file '%s' failed.\n", APath);
+ log_error ("VFSChangeTimes: DateTime modification of the file '%s' failed.", APath);
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "DateTime modification of the file '%s' failed.", APath);
return FALSE;
}
@@ -984,17 +967,17 @@ VFSSetBlockSize (struct TVFSGlobs *globs, guint32 Value)
globs->block_size = Value;
}
-gboolean
+gboolean
VFSIsOnSameFS (struct TVFSGlobs *globs, const char *Path1, const char *Path2, gboolean FollowSymlinks)
{
- printf ("(II) VFSIsOnSameFS: Not supported in ZIP archives.\n");
+ log_debug ("VFSIsOnSameFS: Not supported in ZIP archives.");
return TRUE;
}
gboolean
VFSTwoSameFiles (struct TVFSGlobs *globs, const char *Path1, const char *Path2, gboolean FollowSymlinks)
{
- printf ("(II) VFSTwoSameFiles: Not supported in ZIP archives, comparing by paths.\n");
+ log_debug ("VFSTwoSameFiles: Not supported in ZIP archives, comparing by paths.");
return compare_two_same_files (Path1, Path2);
}
@@ -1008,8 +991,8 @@ VFSStartCopyOperation (struct TVFSGlobs *globs, GError **error)
{
g_return_val_if_fail (globs != NULL, FALSE);
- printf ("(II) VFSStartCopyOperation: doing nothing for the moment.\n");
-
+ log_debug ("VFSStartCopyOperation: doing nothing for the moment.");
+
return TRUE;
}
@@ -1018,24 +1001,24 @@ gboolean
VFSStopCopyOperation (struct TVFSGlobs *globs, GError **error)
{
g_return_val_if_fail (globs != NULL, FALSE);
-
+
if (globs->archive_modified) {
- printf ("(II) VFSStopCopyOperation: rebuilding tree.\n");
+ log_debug ("VFSStopCopyOperation: archive modified, rebuilding the tree.");
globs->zip->FlushBuffers ();
build_global_filelist (globs);
} else {
- printf ("(II) VFSStartCopyOperation: doing nothing for the moment.\n");
+ log_debug ("VFSStartCopyOperation: doing nothing for the moment.");
}
return TRUE;
}
-/* Known issues:
+/* Known issues:
* - crashes when no space left on NFS mounts, probably unhandled exception in further ZipArchive code (repro: Gentoo, Ubuntu)
- *
+ *
**/
-gboolean
+gboolean
VFSCopyToLocal (struct TVFSGlobs *globs, const char *sSrcName, const char *sDstName, gboolean Append, GError **error)
{
gboolean try_again;
@@ -1046,18 +1029,17 @@ VFSCopyToLocal (struct TVFSGlobs *globs, const char *sSrcName, const char *sDstN
char *passwd;
gboolean res;
-
if (sSrcName == NULL || sDstName == NULL || strlen (sSrcName) < 1 || strlen (sDstName) < 1) {
- printf ("(EE) VFSCopyToLocal: The value of 'sSrcName' or 'sDstName' is NULL or empty\n");
+ log_error ("VFSCopyToLocal: The value of 'sSrcName' or 'sDstName' is NULL or empty");
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT, "The value of 'sSrcName' or 'sDstName' is NULL or empty.");
return FALSE;
}
-
- printf ("(II) VFSCopyToLocal: copying file '%s' out to '%s'\n", sSrcName, sDstName);
+
+ log_notice ("VFSCopyToLocal: Copying file '%s' out to '%s'", sSrcName, sDstName);
file_no = filelist_find_original_index_by_path (globs->files, sSrcName) - 1;
if (file_no < 0) {
- printf ("(EE) VFSCopyToLocal: can't find source file '%s'\n", sSrcName);
+ log_error ("VFSCopyToLocal: can't find source file '%s'", sSrcName);
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "cannot find file '%s'", sSrcName);
return FALSE;
}
@@ -1067,39 +1049,39 @@ VFSCopyToLocal (struct TVFSGlobs *globs, const char *sSrcName, const char *sDstN
dest_filename = g_path_get_basename (s);
g_free (s);
- /* Perform extract */
+ /* Perform the extract */
try {
do {
try {
try_again = FALSE;
if (! globs->zip->ExtractFile (file_no, dest_path, false, dest_filename, ZipPlatform::fomRegular, globs->block_size)) {
globs->zip->CloseFile (NULL, true);
- fprintf (stderr, "(EE) VFSCopyToLocal: Error while copying out, archive closed = %d.\n", globs->zip->IsClosed ());
+ log_error ("VFSCopyToLocal: Error while copying out, archive closed = %d.", globs->zip->IsClosed ());
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Error while copying out.");
return FALSE;
- }
- fprintf (stderr, "(II) VFSCopyToLocal: copy OK, archive closed = %d.\n", globs->zip->IsClosed ());
+ }
+ log_debug ("VFSCopyToLocal: copy OK, archive closed = %d.", globs->zip->IsClosed ());
}
catch (CZipException& e) {
globs->zip->CloseFile (NULL, true);
- fprintf (stderr, "(EE) VFSCopyToLocal: Error while copying out: [%d] %s, archive closed = %d.\n",
- e.m_iCause, (LPCTSTR)e.GetErrorDescription(), globs->zip->IsClosed());
+ log_error ("VFSCopyToLocal: Error while copying out: [%d] %s, archive closed = %d.",
+ e.m_iCause, (LPCTSTR)e.GetErrorDescription(), globs->zip->IsClosed());
switch (e.m_iCause) {
case CZipException::badPassword:
if (globs->callback_ask_password) {
passwd = NULL;
- res = globs->callback_ask_password ("The archive is encrypted and requires password",
+ res = globs->callback_ask_password ("The archive is encrypted and requires a password",
NULL, NULL, NULL, (TVFSAskPasswordFlags)(VFS_ASK_PASSWORD_NEED_PASSWORD | VFS_ASK_PASSWORD_ARCHIVE_MODE),
NULL, &passwd, NULL, NULL, NULL,
globs->callback_data);
if (res && passwd) {
- fprintf (stderr, " (II) VFSCopyToLocal: setting password to '%s'\n", passwd);
+ log_debug ("VFSCopyToLocal: setting password to '%s'", passwd);
globs->zip->SetPassword (passwd);
try_again = TRUE;
break;
} else {
- g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_CANCELLED, "Operation has been cancelled.");
- return FALSE;
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_CANCELLED, "Operation has been cancelled.");
+ return FALSE;
}
}
default:
@@ -1111,10 +1093,10 @@ VFSCopyToLocal (struct TVFSGlobs *globs, const char *sSrcName, const char *sDstN
}
catch (...)
{
- fprintf (stderr, "(EE) VFSCopyToLocal: Fatal error while copying out..., archive closed = %d.\n", globs->zip->IsClosed());
- g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Fatal error while copying out.");
+ log_error ("VFSCopyToLocal: Fatal error while copying out..., archive closed = %d.", globs->zip->IsClosed());
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Fatal error while copying out.");
return FALSE;
- }
+ }
g_free (dest_path);
g_free (dest_filename);
@@ -1125,9 +1107,8 @@ VFSCopyToLocal (struct TVFSGlobs *globs, const char *sSrcName, const char *sDstN
/* Known issues:
* - archive corruption when no space left on device
* - encrypted files are unreadable after copy in
- *
**/
-gboolean
+gboolean
VFSCopyFromLocal (struct TVFSGlobs *globs, const char *sSrcName, const char *sDstName, gboolean Append, GError **error)
{
gboolean try_again;
@@ -1136,27 +1117,27 @@ VFSCopyFromLocal (struct TVFSGlobs *globs, const char *sSrcName, const char *sDs
gboolean res;
if (sSrcName == NULL || sDstName == NULL || strlen (sSrcName) < 1 || strlen (sDstName) < 1) {
- printf ("(EE) VFSCopyFromLocal: The value of 'sSrcName' or 'sDstName' is NULL or empty\n");
+ log_error ("VFSCopyFromLocal: The value of 'sSrcName' or 'sDstName' is NULL or empty");
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT, "The value of 'sSrcName' or 'sDstName' is NULL or empty.");
return FALSE;
}
- printf ("(II) VFSCopyFromLocal: copying file '%s' in to '%s'\n", sSrcName, sDstName);
+ log_notice ("VFSCopyFromLocal: Copying file '%s' in to '%s'", sSrcName, sDstName);
try {
do {
try {
- try_again = FALSE;
+ try_again = FALSE;
s = exclude_leading_path_sep (sDstName);
if (! globs->zip->AddNewFile (sSrcName, s, -1, CZipArchive::zipsmSafeSmart, globs->block_size)) {
globs->zip->CloseNewFile (true);
globs->zip->CloseFile (NULL, true);
- fprintf (stderr, "(EE) VFSCopyFromLocal: Error while copying in, archive closed = %d.\n", globs->zip->IsClosed ());
+ log_error ("VFSCopyFromLocal: Error while copying in, archive closed = %d.", globs->zip->IsClosed ());
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Error while copying in.");
return FALSE;
}
- printf ("(II) VFSCopyFromLocal: copy OK, archive closed = %d.\n", globs->zip->IsClosed ());
+ log_debug ("VFSCopyFromLocal: copy OK, archive closed = %d.", globs->zip->IsClosed ());
globs->archive_modified = TRUE;
/*
@@ -1172,30 +1153,30 @@ VFSCopyFromLocal (struct TVFSGlobs *globs, const char *sSrcName, const char *sDs
printf("(EE) VFSCopyFromLocal: Unable to encrypt the newly written file\n");
}
*/
-
+
g_free (s);
}
catch (CZipException& e) {
globs->zip->CloseNewFile (true);
globs->zip->CloseFile (NULL, true);
- fprintf (stderr, "(EE) VFSCopyFromLocal: Error while copying in: [%d] %s, archive closed = %d.\n",
- e.m_iCause, (LPCTSTR)e.GetErrorDescription(), globs->zip->IsClosed());
+ log_error ("VFSCopyFromLocal: Error while copying in: [%d] %s, archive closed = %d.",
+ e.m_iCause, (LPCTSTR)e.GetErrorDescription(), globs->zip->IsClosed());
switch (e.m_iCause) {
case CZipException::badPassword:
if (globs->callback_ask_password) {
passwd = NULL;
- res = globs->callback_ask_password ("The archive is encrypted and requires password",
+ res = globs->callback_ask_password ("The archive is encrypted and requires a password",
NULL, NULL, NULL, (TVFSAskPasswordFlags)(VFS_ASK_PASSWORD_NEED_PASSWORD | VFS_ASK_PASSWORD_ARCHIVE_MODE),
NULL, &passwd, NULL, NULL, NULL,
globs->callback_data);
if (res && passwd) {
- fprintf (stderr, " (II) VFSCopyFromLocal: setting password to '%s'\n", passwd);
+ log_debug ("VFSCopyFromLocal: setting password to '%s'", passwd);
globs->zip->SetPassword (passwd);
try_again = TRUE;
break;
} else {
- g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_CANCELLED, "Operation has been cancelled.");
- return FALSE;
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_CANCELLED, "Operation has been cancelled.");
+ return FALSE;
}
}
default:
@@ -1206,8 +1187,8 @@ VFSCopyFromLocal (struct TVFSGlobs *globs, const char *sSrcName, const char *sDs
} while (try_again);
}
catch (...) {
- fprintf (stderr, "(EE) VFSCopyFromLocal: Fatal error while copying in..., archive closed = %d.\n", globs->zip->IsClosed());
- g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Fatal error while copying in.");
+ log_error ("VFSCopyFromLocal: Fatal error while copying in..., archive closed = %d.", globs->zip->IsClosed());
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Fatal error while copying in.");
return FALSE;
}