00001 /* 00002 * Copyright (C) 2003-2009 Olivier Boudeville 00003 * 00004 * This file is part of the Ceylan library. 00005 * 00006 * The Ceylan library is free software: you can redistribute it and/or modify 00007 * it under the terms of either the GNU Lesser General Public License or 00008 * the GNU General Public License, as they are published by the Free Software 00009 * Foundation, either version 3 of these Licenses, or (at your option) 00010 * any later version. 00011 * 00012 * The Ceylan library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU Lesser General Public License and the GNU General Public License 00016 * for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License and the GNU General Public License along with the Ceylan library. 00020 * If not, see <http://www.gnu.org/licenses/>. 00021 * 00022 * Author: Olivier Boudeville (olivier.boudeville@esperide.com) 00023 * 00024 */ 00025 00026 00027 #ifndef CEYLAN_FILE_SYSTEM_COMMON_H_ 00028 #define CEYLAN_FILE_SYSTEM_COMMON_H_ 00029 00030 00031 00032 #include "CeylanSystem.h" // for SystemException 00033 00034 00035 #include <string> 00036 00037 00038 00039 00040 namespace Ceylan 00041 { 00042 00043 00044 00045 namespace System 00046 { 00047 00048 00049 00050 /* 00051 * Exception declaration section. 00052 * 00053 * Exceptions could be organized by origin (ex: File, Directory, etc.) 00054 * or by theme (ex: creation, opening or removing failed). 00055 * 00056 * We preferred the theme-based organization, so that there are less 00057 * exception conversions to perform when, for example, manipulating 00058 * a filesystem from a File method. 00059 * 00060 * Here are centralized all exceptions that are either at the root 00061 * of file management or possibly thrown by FileSystemManager. 00062 * 00063 * One goal is to avoid having CeylanFile.h and CeylanDirectory.h 00064 * depending on CeylanFileSystemManager.h, because the other way round 00065 * is already true (ex: the factories defined in FileSystemManager 00066 * have to know the file open flags). 00067 * 00068 * Hence CeylanFile.h and CeylanDirectory.h (and 00069 * CeylanFileSystemManager.h) depends on this file. 00070 * 00071 * Some exceptions have to start by the name of their corresponding 00072 * class (ex: FileLookupFailed), as LookupFailed would have to be 00073 * common to File and Directory, and File::LookupFailed cannot be used 00074 * as would be declared in File class but thrown by 00075 * CeylanFileSystemManager, thus recreating a dependency cycle. 00076 * 00077 * As a consequence, we chose to start the names of all file exceptions 00078 * with 'File' and to declare them outside the File class, so that they 00079 * are all handled the same way. 00080 * 00081 * The same process has been applied to Directory exceptions. 00082 * 00083 */ 00084 00085 00086 00092 class CEYLAN_DLL FileManagementException: public SystemException 00093 { 00094 00095 00096 public: 00097 00098 explicit FileManagementException( 00099 const std::string & reason ) : 00100 SystemException( reason ) 00101 { 00102 00103 } 00104 00105 00106 virtual ~FileManagementException() throw() 00107 { 00108 00109 } 00110 00111 } ; 00112 00113 00114 00115 00116 /* 00117 * Three specific child classes for FileManagementException: 00118 * - FileSystemException (defined in FileSystemManager) 00119 * - FileException (defined here to be shared with FileSystemManager) 00120 * - DirectoryException (same thing) 00121 * 00122 */ 00123 00124 00125 00127 class CEYLAN_DLL FileSystemException: public FileManagementException 00128 { 00129 00130 public: 00131 00132 explicit FileSystemException( const std::string & reason ) : 00133 FileManagementException( reason ) 00134 { 00135 00136 } 00137 00138 } ; 00139 00140 00141 00143 class CEYLAN_DLL ConversionFailed: public FileSystemException 00144 { 00145 00146 public: 00147 00148 explicit ConversionFailed( const std::string & reason ) : 00149 FileSystemException( reason ) 00150 { 00151 00152 } 00153 00154 } ; 00155 00156 00157 00159 class CEYLAN_DLL DuplicateFailed: public FileSystemException 00160 { 00161 00162 public: 00163 00164 explicit DuplicateFailed( const std::string & reason ) : 00165 FileSystemException( reason ) 00166 { 00167 00168 } 00169 00170 } ; 00171 00172 00173 00184 class CEYLAN_DLL FileException: public FileManagementException 00185 { 00186 00187 00188 public: 00189 00190 00191 explicit FileException( const std::string & reason ) : 00192 FileManagementException( reason ) 00193 { 00194 00195 } 00196 00197 } ; 00198 00199 00200 00201 00202 00203 // FileException child classes. 00204 00205 00206 00208 class CEYLAN_DLL FileCreationFailed: public FileException 00209 { 00210 00211 public: 00212 00213 explicit FileCreationFailed( const std::string & reason ) : 00214 FileException( reason ) 00215 { 00216 00217 } 00218 00219 00220 } ; 00221 00222 00223 00225 class CEYLAN_DLL FileOpeningFailed: public FileException 00226 { 00227 00228 public: 00229 00230 explicit FileOpeningFailed( const std::string & reason ) : 00231 FileException( reason ) 00232 { 00233 00234 } 00235 00236 00237 } ; 00238 00239 00240 00242 class CEYLAN_DLL FileAlreadyOpened: public FileException 00243 { 00244 00245 public: 00246 00247 explicit FileAlreadyOpened( const std::string & reason ) : 00248 FileException( reason ) 00249 { 00250 00251 } 00252 00253 00254 } ; 00255 00256 00257 00259 class CEYLAN_DLL FileLookupFailed: public FileException 00260 { 00261 00262 public: 00263 00264 explicit FileLookupFailed( const std::string & reason ) : 00265 FileException( reason ) 00266 { 00267 00268 } 00269 00270 00271 } ; 00272 00273 00274 00276 class CEYLAN_DLL FileRemoveFailed: public FileException 00277 { 00278 00279 public: 00280 00281 explicit FileRemoveFailed( const std::string & reason ) : 00282 FileException( reason ) 00283 { 00284 00285 } 00286 00287 00288 } ; 00289 00290 00291 00293 class CEYLAN_DLL FileMoveFailed: public FileException 00294 { 00295 00296 public: 00297 00298 explicit FileMoveFailed( const std::string & reason ) : 00299 FileException( reason ) 00300 { 00301 00302 } 00303 00304 00305 } ; 00306 00307 00308 00310 class CEYLAN_DLL FileCopyFailed: public FileException 00311 { 00312 00313 public: 00314 00315 explicit FileCopyFailed( const std::string & reason ) : 00316 FileException( reason ) 00317 { 00318 00319 } 00320 00321 00322 } ; 00323 00324 00325 00327 class CEYLAN_DLL FileSizeRequestFailed: public FileException 00328 { 00329 00330 public: 00331 00332 explicit FileSizeRequestFailed( const std::string & reason ) : 00333 FileException( reason ) 00334 { 00335 00336 } 00337 00338 00339 } ; 00340 00341 00342 00344 class CEYLAN_DLL FileLastChangeTimeRequestFailed: public FileException 00345 { 00346 00347 public: 00348 00349 explicit FileLastChangeTimeRequestFailed( 00350 const std::string & reason ) : 00351 FileException( reason ) 00352 { 00353 00354 } 00355 00356 00357 } ; 00358 00359 00360 00362 class CEYLAN_DLL FileTouchFailed: public FileException 00363 { 00364 00365 public: 00366 00367 explicit FileTouchFailed( const std::string & reason ) : 00368 FileException( reason ) 00369 { 00370 00371 } 00372 00373 00374 } ; 00375 00376 00377 00379 class CEYLAN_DLL FileDiffFailed: public FileException 00380 { 00381 00382 public: 00383 00384 explicit FileDiffFailed( const std::string & reason ) : 00385 FileException( reason ) 00386 { 00387 00388 } 00389 00390 00391 } ; 00392 00393 00394 00395 00396 00397 // Directory section. 00398 00399 00400 00411 class CEYLAN_DLL DirectoryException: public FileManagementException 00412 { 00413 00414 public: 00415 00416 explicit DirectoryException( const std::string & reason ) : 00417 FileManagementException( reason ) 00418 { 00419 00420 } 00421 00422 } ; 00423 00424 00425 00426 00427 // DirectoryException child classes. 00428 00429 00431 class CEYLAN_DLL DirectoryCreationFailed: public DirectoryException 00432 { 00433 00434 public: 00435 00436 explicit DirectoryCreationFailed( const std::string & reason ) : 00437 DirectoryException( reason ) 00438 { 00439 00440 } 00441 00442 00443 } ; 00444 00445 00446 00448 class CEYLAN_DLL DirectoryOpeningFailed: public DirectoryException 00449 { 00450 00451 public: 00452 00453 explicit DirectoryOpeningFailed( const std::string & reason ) : 00454 DirectoryException( reason ) 00455 { 00456 00457 } 00458 00459 00460 } ; 00461 00462 00463 00465 class CEYLAN_DLL DirectoryLookupFailed: public DirectoryException 00466 { 00467 00468 public: 00469 00470 explicit DirectoryLookupFailed( const std::string & reason ) : 00471 DirectoryException( reason ) 00472 { 00473 00474 } 00475 00476 00477 } ; 00478 00479 00480 00482 class CEYLAN_DLL DirectoryRemoveFailed: public DirectoryException 00483 { 00484 00485 public: 00486 00487 explicit DirectoryRemoveFailed( const std::string & reason ) : 00488 DirectoryException( reason ) 00489 { 00490 00491 } 00492 00493 00494 } ; 00495 00496 00497 00499 class CEYLAN_DLL DirectoryMoveFailed: public DirectoryException 00500 { 00501 00502 public: 00503 00504 explicit DirectoryMoveFailed( const std::string & reason ) : 00505 DirectoryException( reason ) 00506 { 00507 00508 } 00509 00510 00511 } ; 00512 00513 00514 00516 class CEYLAN_DLL DirectoryCopyFailed: public DirectoryException 00517 { 00518 00519 public: 00520 00521 explicit DirectoryCopyFailed( const std::string & reason ) : 00522 DirectoryException( reason ) 00523 { 00524 00525 } 00526 00527 00528 } ; 00529 00530 00531 00533 class CEYLAN_DLL DirectoryLastChangeTimeRequestFailed: 00534 public DirectoryException 00535 { 00536 00537 public: 00538 00539 explicit DirectoryLastChangeTimeRequestFailed( 00540 const std::string & reason ) : 00541 DirectoryException( reason ) 00542 { 00543 00544 } 00545 00546 00547 } ; 00548 00549 00550 00552 class CEYLAN_DLL DirectoryGetCurrentFailed: public DirectoryException 00553 { 00554 00555 public: 00556 00557 explicit DirectoryGetCurrentFailed( 00558 const std::string & reason ) : 00559 DirectoryException( reason ) 00560 { 00561 00562 } 00563 00564 00565 } ; 00566 00567 00568 00570 class CEYLAN_DLL DirectoryChangeFailed: public DirectoryException 00571 { 00572 00573 public: 00574 00575 explicit DirectoryChangeFailed( const std::string & reason ) : 00576 DirectoryException( reason ) 00577 { 00578 00579 } 00580 00581 00582 } ; 00583 00584 00585 00586 } 00587 00588 } 00589 00590 00591 00592 #endif // CEYLAN_FILE_SYSTEM_COMMON_H_ 00593