2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file FIoFileAttributes.h
19 * @brief This is the header file for the %FileAttributes class.
21 * This header file contains the declarations of the %FileAttributes class.
24 #ifndef _FIO_FILE_ATTRIBUTES_H_
25 #define _FIO_FILE_ATTRIBUTES_H_
27 #include <FBaseObject.h>
29 namespace Tizen { namespace Base
34 namespace Tizen { namespace Io
38 * @class FileAttributes
39 * @brief This class provides a collection of basic file attributes.
43 * @final This class is not intended for extension.
45 * The %FileAttributes class provides the attributes of a file or directory.
46 * It can be used to determine the various file properties such as file attributes
47 * (read-only, hidden, system, or directory), creation time, last modified time, and file size.
49 * For more information on the class features,
50 * see <a href="../org.tizen.native.appprogramming/html/guide/io/io_namespace.htm">Io Guide</a>.
52 * The following example demonstrates how to use the %FileAttributes class.
58 using namespace Tizen::Base;
59 using namespace Tizen::Io;
63 String fileName(L"test.txt");
71 r = File::GetAttributes(App::GetInstance()->GetAppDataPath() + fileName, attr);
77 size = attr.GetFileSize();
78 AppLog("* size=%d", size);
80 dtCreate = attr.GetDateTime();
81 AppLog("* creation time: %d year, %d month, %d day, %d hour, %d min, %d sec.\n",
90 dtModified = attr.GetLastModifiedTime();
91 AppLog("* last modified time: %d year, %d month, %d day, %d hour, %d min, %d sec.\n",
93 dtModified.GetMonth(),
96 dtModified.GetMinute(),
97 dtModified.GetSecond()
100 if (attr.IsDirectory())
102 AppLog("* This is a directory.");
106 AppLog("* This is a hidden file.");
108 if (attr.IsReadOnly())
110 AppLog("* This is a read-only file.");
113 AppLog("Succeeded!");
122 class _OSP_EXPORT_ FileAttributes
123 : public Tizen::Base::Object
128 * This is the default constructor for this class.
132 FileAttributes(void);
135 * This destructor overrides Tizen::Base::Object::~Object().
139 virtual ~FileAttributes(void);
142 * Copying of objects using this copy constructor is allowed.
146 * @param[in] rhs An instance of %FileAttributes
148 FileAttributes(const FileAttributes& rhs);
151 * Assigns the value of the specified instance to the current instance of %FileAttributes.
155 * @return The reference of this instance
156 * @param[in] rhs An instance of %FileAttributes
158 FileAttributes& operator =(const FileAttributes& rhs);
161 * Compares the specified instance of Object to the calling instance of %FileAttributes.
165 * @return @c true if the values of the specified instance equals the values of the current instance, @n
167 * @param[in] object The object to compare with the current instance
169 virtual bool Equals(const Tizen::Base::Object& object) const;
172 * Gets the hash value of the current instance.
176 * @return An integer value indicating the hash value of the current instance
178 virtual int GetHashCode(void) const;
181 * Gets the file size.
185 * @return The file size in bytes
187 long long GetFileSize(void) const;
190 * Checks whether the current file is a directory.
194 * @return @c true if the file is a directory, @n
197 bool IsDirectory(void) const;
200 * Checks whether the file has a hidden attribute.
204 * @return @c true if the file has a hidden attribute, @n
207 bool IsHidden(void) const;
210 * Checks whether the file has a read-only attribute.
214 * @return @c true if the file has a read-only attribute, @n
217 bool IsReadOnly(void) const;
220 * Gets the date and time of the last modification to the file.
224 * @return The date and time of the last modification to the file
226 Tizen::Base::DateTime GetDateTime(void) const;
229 * Gets the date and time of the last modification to the file.
233 * @return The date and time of the last modification to the file
235 Tizen::Base::DateTime GetLastModifiedTime(void) const;
238 class _FileAttributesImpl* __pFileAttributesImpl;
240 friend class _FileAttributesImpl;
246 #endif //_FIO_FILE_ATTRIBUTES_H_