merge the formfield patch from ooo-build
[ooovba.git] / configmgr / source / inc / filehelper.hxx
blob30677ed51144e59156773cdaf1d13ac7706d9df5
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: filehelper.hxx,v $
10 * $Revision: 1.14 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _CONFIGMGR_FILEHELPER_HXX_
32 #define _CONFIGMGR_FILEHELPER_HXX_
34 #include "utility.hxx"
35 #include <osl/file.hxx>
36 #include <com/sun/star/io/IOException.hpp>
38 namespace io = com::sun::star::io;
40 namespace configmgr
42 //==========================================================================
43 //= FileHelper
44 //==========================================================================
45 /** Within the FileHelper namespace there is a list of methods declared, which ease
46 specific file operations.
48 namespace FileHelper
50 /// delimiter used in URLs and ConfPath
51 static const ::sal_Unicode delimiter = sal_Unicode('/');
53 /// Tests if the file exists.
54 bool fileExists(rtl::OUString const& _sFileURL);
56 /// Tests if the directory exists.
57 bool dirExists(rtl::OUString const& _sDirURL);
59 /** Returns the parent part of the pathname of this File URL,
60 or an empty string if the name has no parent part.
61 The parent part is generally everything leading up to the last occurrence
62 of the separator character.
64 rtl::OUString getParentDir(rtl::OUString const& _aFileURL);
66 /**
67 Returns the file name part of a file URL.
69 @param aFileUrl file URL
70 @return everything in the URL from the last delimiter on
72 rtl::OUString getFileName(const rtl::OUString& aFileUrl) ;
74 /**
75 Splits a file URL between its parent directory/file name
76 parts.
78 @param aFileUrl file URL
79 @param aParentDirectory parent directory filled on return
80 @param aFileName file name filled on return
82 void splitFileUrl(const rtl::OUString& aFileUrl,
83 rtl::OUString& aParentDirectory,
84 rtl::OUString& aFileName) ;
86 /** creates a directory whose pathname is specified by a FileURL.
87 @return true if directory could be created or does exist, otherwise false.
89 osl::FileBase::RC mkdir(rtl::OUString const& _sDirURL);
91 /** creates a directory whose pathname is specified by a FileURL,
92 including any necessary parent directories.
93 @return true if directory (or directories) could be created or do(es) exist, otherwise false.
95 osl::FileBase::RC mkdirs(rtl::OUString const& _aDirectory);
97 /** replaces a file specified by _aToURL with a file specified by _aFromURL.
99 void replaceFile(const rtl::OUString& _aToURL, const rtl::OUString &_aFromURL) SAL_THROW((io::IOException));
101 /** removes a file specified by _aURL. Ignores the case of a non-existing file.
103 bool tryToRemoveFile(const rtl::OUString& _aURL, bool tryBackupFirst);
105 /** creates an error msg string for a given file error return code.
107 rtl::OUString createOSLErrorString(osl::FileBase::RC eError);
109 /** determines the status of a directory entry specified by a URL.
110 @return the Size of the file in bytes and the TimeValue of the last modification, if the file exists,
111 otherwise 0 and a TimeValue(0,0).
113 sal_uInt64 getModifyStatus(rtl::OUString const& _aNormalizedFilename, TimeValue & rModifyTime);
115 } // namespace configmgr
117 #endif