libgnomevfsmm  2.26.0
handle.h
Go to the documentation of this file.
1 /* $Id: handle.h 2019 2009-01-27 08:29:42Z murrayc $ */
2 
3 /* Copyright 2003 gnome-vfsmm Development Team
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library 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 GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free
17  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 
20 
21 #ifndef _LIBGNOMEVFSMM_HANDLE_H
22 #define _LIBGNOMEVFSMM_HANDLE_H
23 
24 #include <glibmm.h>
25 
26 #include <libgnomevfs/gnome-vfs-ops.h>
27 
28 #include <libgnomevfsmm/uri.h>
31 #include <libgnomevfsmm/enums.h>
32 #include <libgnomevfsmm/types.h>
33 
34 
35 #ifndef DOXYGEN_SHOULD_SKIP_THIS
36 typedef struct GnomeVFSHandle GnomeVFSHandle;
37 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
38 
39 namespace Gnome
40 {
41 
42 namespace Vfs
43 {
44 
45 class Handle
46 {
47 public:
48  Handle();
49  virtual ~Handle();
50 
51 #ifdef GLIBMM_EXCEPTIONS_ENABLED
52  void open(const Glib::ustring& text_uri, OpenMode open_mode) throw(exception);
53  void open(const Glib::RefPtr<const Uri>& uri, OpenMode open_mode) throw(exception);
54 
55  void create(const Glib::ustring& text_uri, OpenMode open_mode, bool exclusive, guint permissions) throw(exception);
56  void create(const Glib::RefPtr<const Uri>& uri, OpenMode open_mode, bool exclusive, guint permissions) throw(exception);
57 
58  void close() throw(exception);
59 
60  FileSize read(gpointer buffer, FileSize bytes) throw(exception);
61 
62  FileSize write(gconstpointer buffer, FileSize bytes) throw(exception);
63 
64  void seek(SeekPosition whence, FileOffset offset) throw(exception);
65 
66  FileSize tell() throw(exception);
67 
68  static Glib::RefPtr<FileInfo> get_file_info(const Glib::ustring& text_uri, FileInfoOptions options = FILE_INFO_DEFAULT) throw(exception);
69 
70  Glib::RefPtr<FileInfo> get_file_info(FileInfoOptions options = FILE_INFO_DEFAULT) const throw(exception);
71 
72 
73  static void truncate(const Glib::ustring& text_uri, FileSize length) throw(exception);
74  static void truncate(const Glib::RefPtr<const Uri>& uri, FileSize length) throw(exception);
75  void truncate(FileSize length) throw(exception);
76 
77  static void make_directory(const Glib::ustring& text_uri, guint permissions) throw(exception);
78  static void make_directory(const Glib::RefPtr<const Uri>& uri, guint permissions) throw(exception);
79 
80  static void remove_directory(const Glib::ustring& text_uri) throw(exception);
81  static void remove_directory(const Glib::RefPtr<const Uri>& uri) throw(exception);
82 
83  static void unlink(const Glib::ustring& text_uri) throw(exception);
84  static void unlink(const Glib::RefPtr<const Uri>& uri) throw(exception);
85 
86  static void move(const Glib::ustring& old_text_uri, const Glib::ustring& new_text_uri, bool force_replace) throw(exception);
87  static void move(const Glib::RefPtr<const Uri>& old_uri, const Glib::RefPtr<const Uri>& new_uri, bool force_replace) throw(exception);
88 
89  static bool check_same_fs(const Glib::ustring& source, const Glib::ustring& target) throw(exception);
90  static bool check_same_fs(const Glib::RefPtr<const Uri>& source, const Glib::RefPtr<const Uri>& target) throw(exception);
91 
92  bool uri_exists(const Glib::RefPtr<const Uri>& uri) throw(exception);
93 
94  static void set_file_info(const Glib::ustring& text_uri, const Glib::RefPtr<const FileInfo>& info, SetFileInfoMask mask) throw(exception);
95  static void set_file_info(const Glib::RefPtr<const Uri>& uri, const Glib::RefPtr<const FileInfo>& info, SetFileInfoMask mask) throw(exception);
96 
97  void file_control(const Glib::ustring& operation, gpointer operation_data) throw(exception);
98 #else
99  void open(const Glib::ustring& text_uri, OpenMode open_mode, std::auto_ptr<Gnome::Vfs::exception>& error);
100  void open(const Glib::RefPtr<const Uri>& uri, OpenMode open_mode, std::auto_ptr<Gnome::Vfs::exception>& error);
101 
102  void create(const Glib::ustring& text_uri, OpenMode open_mode, bool exclusive, guint permissions, std::auto_ptr<Gnome::Vfs::exception>& error);
103  void create(const Glib::RefPtr<const Uri>& uri, OpenMode open_mode, bool exclusive, guint permissions, std::auto_ptr<Gnome::Vfs::exception>& error);
104 
105  void close(std::auto_ptr<Gnome::Vfs::exception>& error);
106 
107  FileSize read(gpointer buffer, FileSize bytes, std::auto_ptr<Gnome::Vfs::exception>& error);
108 
109  FileSize write(gconstpointer buffer, FileSize bytes, std::auto_ptr<Gnome::Vfs::exception>& error);
110 
111  void seek(SeekPosition whence, FileOffset offset, std::auto_ptr<Gnome::Vfs::exception>& error);
112 
113  FileSize tell(std::auto_ptr<Gnome::Vfs::exception>& error);
114 
115  static Glib::RefPtr<FileInfo> get_file_info(const Glib::ustring& text_uri, FileInfoOptions options, std::auto_ptr<Gnome::Vfs::exception>& error);
116 
117  Glib::RefPtr<FileInfo> get_file_info(FileInfoOptions options, std::auto_ptr<Gnome::Vfs::exception>& error) const;
118 
119 
120  static void truncate(const Glib::ustring& text_uri, FileSize length, std::auto_ptr<Gnome::Vfs::exception>& error);
121  static void truncate(const Glib::RefPtr<const Uri>& uri, FileSize length, std::auto_ptr<Gnome::Vfs::exception>& error);
122  void truncate(FileSize length, std::auto_ptr<Gnome::Vfs::exception>& error);
123 
124  static void make_directory(const Glib::ustring& text_uri, guint permissions, std::auto_ptr<Gnome::Vfs::exception>& error);
125  static void make_directory(const Glib::RefPtr<const Uri>& uri, guint permissions, std::auto_ptr<Gnome::Vfs::exception>& error);
126 
127  static void remove_directory(const Glib::ustring& text_uri, std::auto_ptr<Gnome::Vfs::exception>& error);
128  static void remove_directory(const Glib::RefPtr<const Uri>& uri, std::auto_ptr<Gnome::Vfs::exception>& error);
129 
130  static void unlink(const Glib::ustring& text_uri, std::auto_ptr<Gnome::Vfs::exception>& error);
131  static void unlink(const Glib::RefPtr<const Uri>& uri, std::auto_ptr<Gnome::Vfs::exception>& error);
132 
133  static void move(const Glib::ustring& old_text_uri, const Glib::ustring& new_text_uri, bool force_replace, std::auto_ptr<Gnome::Vfs::exception>& error);
134  static void move(const Glib::RefPtr<const Uri>& old_uri, const Glib::RefPtr<const Uri>& new_uri, bool force_replace, std::auto_ptr<Gnome::Vfs::exception>& error);
135 
136  static bool check_same_fs(const Glib::ustring& source, const Glib::ustring& target, std::auto_ptr<Gnome::Vfs::exception>& error);
137  static bool check_same_fs(const Glib::RefPtr<const Uri>& source, const Glib::RefPtr<const Uri>& target, std::auto_ptr<Gnome::Vfs::exception>& error);
138 
139  bool uri_exists(const Glib::RefPtr<const Uri>& uri, std::auto_ptr<Gnome::Vfs::exception>& error);
140 
141  static void set_file_info(const Glib::ustring& text_uri, const Glib::RefPtr<const FileInfo>& info, SetFileInfoMask mask, std::auto_ptr<Gnome::Vfs::exception>& error);
142  static void set_file_info(const Glib::RefPtr<const Uri>& uri, const Glib::RefPtr<const FileInfo>& info, SetFileInfoMask mask, std::auto_ptr<Gnome::Vfs::exception>& error);
143 
144  void file_control(const Glib::ustring& operation, gpointer operation_data, std::auto_ptr<Gnome::Vfs::exception>& error);
145 #endif //GLIBMM_EXCEPTIONS_ENABLED
146 
147 
148  GnomeVFSHandle* gobj();
149  const GnomeVFSHandle* gobj() const;
150 
151 
152 protected:
153 
154  GnomeVFSHandle* gobj_;
155 };
156 
157 } // namespace Vfs
158 } // namespace Gnome
159 
160 
161 
162 
163 #endif /* _LIBGNOMEVFSMM_HANDLE_H */
164