You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
106 lines
4.8 KiB
106 lines
4.8 KiB
15 years ago
|
/* Load / save entire (local) files with nice diagnostics dialog messages.
|
||
|
* These functions load/save the whole buffer in one i/o call, so they
|
||
|
* should be pretty efficient.
|
||
|
*
|
||
|
* Author: Stefan Taferner <taferner@kde.org>
|
||
|
* This code is under GPL.
|
||
|
*/
|
||
12 years ago
|
#ifndef kpim_tdefileio_h
|
||
|
#define kpim_tdefileio_h
|
||
15 years ago
|
|
||
15 years ago
|
#include <tqcstring.h>
|
||
|
#include <tqwidget.h>
|
||
15 years ago
|
|
||
13 years ago
|
#include <tdepimmacros.h>
|
||
15 years ago
|
|
||
15 years ago
|
class TQString;
|
||
15 years ago
|
|
||
|
namespace KPIM {
|
||
|
|
||
13 years ago
|
/** Load a file. Returns a pointer to the memory-block that contains
|
||
15 years ago
|
* the loaded file. Returns a null string if the file could not be loaded.
|
||
|
* If withDialogs is FALSE no warning dialogs are opened if there are
|
||
|
* problems.
|
||
|
* The string returned is always zero-terminated and therefore one
|
||
|
* byte longer than the file itself.
|
||
|
* If ensureNewline is TRUE the string will always have a trailing newline.
|
||
|
*/
|
||
15 years ago
|
TQCString kFileToString(const TQString &fileName, bool ensureNewline=true,
|
||
15 years ago
|
bool withDialogs=true) KDE_EXPORT;
|
||
|
|
||
|
// unused
|
||
15 years ago
|
//TQByteArray kFileToBytes(const TQString &fileName, bool withDialogs=true);
|
||
15 years ago
|
|
||
|
|
||
|
/** Save a file. If withDialogs is FALSE no warning dialogs are opened if
|
||
|
* there are problems. Returns TRUE on success and FALSE on failure.
|
||
|
* Replaces existing files without warning if askIfExists==FALSE.
|
||
|
* Makes a copy if the file exists to filename~ if createBackup==TRUE.
|
||
|
*/
|
||
|
bool kBytesToFile(const char* aBuffer, int len,
|
||
15 years ago
|
const TQString &aFileName,
|
||
15 years ago
|
bool aAskIfExists, bool aBackup, bool aVerbose) KDE_EXPORT;
|
||
|
|
||
15 years ago
|
bool kCStringToFile(const TQCString& buffer, const TQString &fileName,
|
||
15 years ago
|
bool askIfExists=false, bool createBackup=true,
|
||
|
bool withDialogs=true) KDE_EXPORT;
|
||
|
/** Does not stop at NUL */
|
||
15 years ago
|
KDE_EXPORT bool kByteArrayToFile(const TQByteArray& buffer, const TQString &fileName,
|
||
15 years ago
|
bool askIfExists=false, bool createBackup=true,
|
||
|
bool withDialogs=true) KDE_EXPORT;
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Checks and corrects the permissions of a file or folder, and if requested
|
||
|
* all files and folders below. It gives back a list of files which do not
|
||
|
* have the right permissions. This list can be used to show to the user.
|
||
|
*
|
||
|
* @param toCheck The file or folder of which the permissions should
|
||
|
* be checked.
|
||
|
* @param recursive Set to true, it will check the contents of a folder
|
||
|
* for the permissions recursively. If false only
|
||
|
* toCheck will be checked.
|
||
|
* @param wantItReadable Set to true, it will check for read permissions.
|
||
|
* If the read permissions are not available, there will
|
||
|
* be a attempt to correct this.
|
||
|
* @param wantItWritable Set to true, it will check for write permissions.
|
||
|
* If the write permissions are not available, there
|
||
|
* will be a attempt to correct this.
|
||
|
* @return It will return a string with all files and folders which do not
|
||
|
* have the right permissions. If empty, then all permissions are ok.
|
||
|
*/
|
||
15 years ago
|
TQString checkAndCorrectPermissionsIfPossible( const TQString &toCheck,
|
||
15 years ago
|
const bool recursive, const bool wantItReadable,
|
||
|
const bool wantItWritable );
|
||
|
|
||
|
/**
|
||
|
* Checks and corrects the permissions of a file or folder, and if requested
|
||
|
* all files and folders below. If the permissions are not ok, it tries to correct
|
||
|
* them. If that fails then a warning with detailled information is given.
|
||
|
*
|
||
13 years ago
|
* @param parent If parent is 0, then the message box becomes an
|
||
|
* application-global modal dialog box. If parent
|
||
15 years ago
|
* is a widget, the message box becomes modal
|
||
13 years ago
|
* relative to parent.
|
||
15 years ago
|
* @param toCheck The file or folder of which the permissions should
|
||
|
* be checked.
|
||
|
* @param recursive Set to true, it will check the contents of a folder
|
||
|
* for the permissions recursively. If false only
|
||
|
* toCheck will be checked.
|
||
|
* @param wantItReadable Set to true, it will check for read permissions.
|
||
|
* If the read permissions are not available, there will
|
||
|
* be a attempt to correct this.
|
||
|
* @param wantItWritable Set to true, it will check for write permissions.
|
||
|
* If the write permissions are not available, there
|
||
|
* will be a attempt to correct this.
|
||
|
* @return It will return true if all permissions in the end are ok. If false
|
||
|
* then the permissions are not ok and it was not possible to correct
|
||
|
* all errors.
|
||
|
*/
|
||
13 years ago
|
bool checkAndCorrectPermissionsIfPossibleWithErrorHandling( TQWidget *parent,
|
||
15 years ago
|
const TQString &toCheck, const bool recursive, const bool wantItReadable,
|
||
15 years ago
|
const bool wantItWritable );
|
||
|
}
|
||
|
|
||
12 years ago
|
#endif /*kpim_tdefileio_h*/
|