libktorrent  2.2.0
fileops.h
1 /***************************************************************************
2  * Copyright (C) 2005 by Joris Guisson *
3  * joris.guisson@gmail.com *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 #ifndef BTFILEOPS_H
21 #define BTFILEOPS_H
22 
23 #include <util/constants.h>
24 #include <ktorrent_export.h>
25 #include <QByteArray>
26 
27 class QString;
28 
29 #ifdef CopyFile
30 #undef CopyFile
31 #endif
32 
33 namespace bt
34 {
35 
42  KTORRENT_EXPORT void MakeDir(const QString & dir,bool nothrow = false);
43 
50  KTORRENT_EXPORT void MakePath(const QString & dir,bool nothrow = false);
51 
58  KTORRENT_EXPORT void MakeFilePath(const QString & file,bool nothrow = false);
59 
66  KTORRENT_EXPORT void SymLink(const QString & link_to,const QString & link_url,bool nothrow = false);
67 
75  KTORRENT_EXPORT void Move(const QString & src,const QString & dst,bool nothrow = false,bool silent = false);
76 
83  KTORRENT_EXPORT void CopyFile(const QString & src,const QString & dst,bool nothrow = false);
84 
91  KTORRENT_EXPORT void CopyDir(const QString & src,const QString & dst,bool nothrow = false);
92 
98  KTORRENT_EXPORT bool Exists(const QString & url);
99 
105  KTORRENT_EXPORT void Delete(const QString & url,bool nothrow = false);
106 
113  KTORRENT_EXPORT void Touch(const QString & url,bool nothrow = false);
114 
121  KTORRENT_EXPORT Uint64 FileSize(const QString & url);
122 
129  KTORRENT_EXPORT Uint64 FileSize(int fd);
130 
138  KTORRENT_EXPORT void TruncateFile(int fd,Uint64 size,bool quick);
139 
146  KTORRENT_EXPORT void TruncateFile(const QString & path,Uint64 size);
147 
148 #ifdef HAVE_XFS_XFS_H
149 
152  KTORRENT_EXPORT bool XfsPreallocate(int fd,Uint64 size);
153 
157  KTORRENT_EXPORT bool XfsPreallocate(const QString & path,Uint64 size);
158 
159 #endif
160 
168  KTORRENT_EXPORT void SeekFile(int fd,Int64 off,int whence);
169 
171  KTORRENT_EXPORT bool FreeDiskSpace(const QString & path,Uint64 & bytes_free);
172 
174  KTORRENT_EXPORT bool FileNameToLong(const QString & path);
175 
182  KTORRENT_EXPORT QString ShortenFileName(const QString & path,int extra_number = -1);
183 
185  KTORRENT_EXPORT Uint64 DiskUsage(const QString & filename);
186 
188  KTORRENT_EXPORT Uint64 DiskUsage(int fd);
189 
191  KTORRENT_EXPORT QString MountPoint(const QString & path);
192 
194  KTORRENT_EXPORT bool IsMounted(const QString & mount_point);
195 
197  KTORRENT_EXPORT QByteArray LoadFile(const QString & path);
198 }
199 
200 #endif