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