00001 /* 00002 ** This file is part of Vidalia, and is subject to the license terms in the 00003 ** LICENSE file, found in the top level directory of this distribution. If you 00004 ** did not receive the LICENSE file with this file, you may obtain it from the 00005 ** Vidalia source package distributed by the Vidalia Project at 00006 ** http://www.vidalia-project.net/. No part of Vidalia, including this file, 00007 ** may be copied, modified, propagated, or distributed except according to the 00008 ** terms described in the LICENSE file. 00009 */ 00010 00011 /* 00012 ** \file file.h 00013 ** \version $Id: file.h 3505 2009-02-03 02:21:55Z edmanm $ 00014 ** \brief Functions and definitions for common file I/O operations 00015 */ 00016 00017 #ifndef _FILE_H 00018 #define _FILE_H 00019 00020 #include <QString> 00021 00022 00023 /** Create an empty file named <b>filename</b>. if <b>createdir</b> is true, 00024 * then the full path to <b>filename</b> will be created. Returns true on 00025 * success, or false on error and <b>errmsg</b> will be set. */ 00026 bool touch_file(const QString &filename, bool createdir = false, 00027 QString *errmsg = 0); 00028 00029 /** Creates all directories in <b>path</b>, if they do not exist. */ 00030 bool create_path(const QString &path); 00031 00032 /** Expands <b>filename</b> if it starts with "~/". On Windows, this will 00033 * expand "%APPDATA%" and "%PROGRAMFILES%". If <b>filename</b> does not 00034 * start with a shortcut, <b>filename</b> will be returned unmodified. */ 00035 QString expand_filename(const QString &filename); 00036 00037 /** Recursively copy the contents of one directory to another. The 00038 * destination must already exist. Returns true on success, and false 00039 * otherwise. */ 00040 bool copy_dir(const QString &source, const QString &dest); 00041 00042 #endif 00043