3 /***************************************************************************
8 * begin : Tue Jan 29 2002
9 * copyright : (C) 2002 by Patrick Charbonnier
11 * email : pch@freeshell.org
13 ***************************************************************************/
15 /* Load / save entire (local) files with nice diagnostics dialog messages.
16 * These functions load/save the whole buffer in one i/o call, so they
17 * should be pretty efficient.
19 * Author: Stefan Taferner <taferner@kde.org>
20 * This code is under GPL.
25 /** Load a file. Returns a pointer to the memory-block that contains
26 * the loaded file. Returns a NULL string if the file could not be loaded.
27 * If withDialogs is FALSE no warning dialogs are opened if there are
29 * The string returned is always zero-terminated and therefore one
30 * byte longer than the file itself.
31 * If ensureNewline is TRUE the string will always have a trailing newline.
33 QString
kFileToString(const QString
& fileName
, bool ensureNewline
= TRUE
, bool withDialogs
= TRUE
);
35 /** Save a file. If withDialogs is FALSE no warning dialogs are opened if
36 * there are problems. Returns TRUE on success and FALSE on failure.
37 * Replaces existing files without warning if askIfExists==FALSE.
38 * Makes a copy if the file exists to filename~ if createBackup==TRUE.
40 bool kCStringToFile(const Q3CString
& buffer
, const QString
& fileName
, bool askIfExists
= FALSE
, bool createBackup
= TRUE
, bool withDialogs
= TRUE
);
42 // Does not stop at NUL
43 bool kByteArrayToFile(const QByteArray
& buffer
, const QString
& fileName
, bool askIfExists
= FALSE
, bool createBackup
= TRUE
, bool withDialogs
= TRUE
);
46 #endif /* kfileio_h */