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 methods for 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");
67 DateTime modifiedTime;
70 r = File::GetAttributes(App::GetInstance()->GetAppDataPath() + fileName, attr);
76 size = attr.GetFileSize();
77 AppLog("File size: %d", size);
79 modifiedTime = attr.GetLastModifiedTime();
80 AppLog("Last modified time: %d year, %d month, %d day, %d hour, %d min, %d sec.\n",
81 modifiedTime.GetYear(),
82 modifiedTime.GetMonth(),
83 modifiedTime.GetDay(),
84 modifiedTime.GetHour(),
85 modifiedTime.GetMinute(),
86 modifiedTime.GetSecond()
89 if (attr.IsDirectory())
91 AppLog("This is a directory.");
95 AppLog("This is a hidden file.");
107 class _OSP_EXPORT_ FileAttributes
108 : public Tizen::Base::Object
113 * This is the default constructor for this class.
117 FileAttributes(void);
120 * This destructor overrides Tizen::Base::Object::~Object().
124 virtual ~FileAttributes(void);
127 * Copying of objects using this copy constructor is allowed.
131 * @param[in] rhs An instance of %FileAttributes
133 FileAttributes(const FileAttributes& rhs);
136 * Assigns the specified value of the specified instance to the current instance of %FileAttributes.
140 * @return The reference of this instance
141 * @param[in] rhs An instance of %FileAttributes
143 FileAttributes& operator =(const FileAttributes& rhs);
146 * Compares the specified instance of Tizen::Base::Object to the current instance of %FileAttributes.
150 * @return @c true if the values of the specified instance equals the values of the current instance, @n
152 * @param[in] object The object to compare with the current instance
154 virtual bool Equals(const Tizen::Base::Object& object) const;
157 * Gets the hash value of the current instance.
161 * @return An integer value indicating the hash value of the current instance
163 virtual int GetHashCode(void) const;
166 * Gets the file size.
170 * @return The file size in bytes
172 long long GetFileSize(void) const;
175 * Checks whether the current file is a directory.
179 * @return @c true if the file is a directory, @n
182 bool IsDirectory(void) const;
185 * Checks whether the file has a hidden attribute.
189 * @return @c true if the file has a hidden attribute, @n
192 bool IsHidden(void) const;
195 * Checks whether the file has a read-only attribute.
199 * @return @c true if the file has a read-only attribute, @n
202 bool IsReadOnly(void) const;
205 * Gets the date and time of the last modification to the file.
209 * @return The date and time of the last modification to the file
211 Tizen::Base::DateTime GetDateTime(void) const;
214 * Gets the date and time of the last modification to the file.
218 * @return The date and time of the last modification to the file
220 Tizen::Base::DateTime GetLastModifiedTime(void) const;
223 class _FileAttributesImpl* __pFileAttributesImpl;
225 friend class _FileAttributesImpl;
231 #endif //_FIO_FILE_ATTRIBUTES_H_