2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FIoFileAttributes.h
20 * @brief This is the header file for the %FileAttributes class.
22 * This header file contains the declarations of the %FileAttributes class.
25 #ifndef _FIO_FILE_ATTRIBUTES_H_
26 #define _FIO_FILE_ATTRIBUTES_H_
28 #include <FBaseObject.h>
30 namespace Tizen { namespace Base
35 namespace Tizen { namespace Io
39 * @class FileAttributes
40 * @brief This class provides a collection of basic file attributes.
44 * @final This class is not intended for extension.
46 * The %FileAttributes class provides the attributes of a file or directory.
47 * It can be used to determine the various file properties such as file attributes
48 * (read-only, hidden, system, or directory), creation time, last modified time, and file size.
50 * For more information on the class features,
51 * see <a href="../org.tizen.native.appprogramming/html/guide/io/io_namespace.htm">Io Guide</a>.
53 * The following example demonstrates how to use the %FileAttributes class.
59 using namespace Tizen::Base;
60 using namespace Tizen::Io;
64 String fileName(L"test.txt");
72 r = File::GetAttributes(App::GetInstance()->GetAppDataPath() + fileName, attr);
78 size = attr.GetFileSize();
79 AppLog("* size=%d", size);
81 dtCreate = attr.GetDateTime();
82 AppLog("* creation time: %d year, %d month, %d day, %d hour, %d min, %d sec.\n",
91 dtModified = attr.GetLastModifiedTime();
92 AppLog("* last modified time: %d year, %d month, %d day, %d hour, %d min, %d sec.\n",
94 dtModified.GetMonth(),
97 dtModified.GetMinute(),
98 dtModified.GetSecond()
101 if (attr.IsDirectory())
103 AppLog("* This is a directory.");
107 AppLog("* This is a hidden file.");
109 if (attr.IsReadOnly())
111 AppLog("* This is a read-only file.");
114 AppLog("Succeeded!");
123 class _OSP_EXPORT_ FileAttributes
124 : public Tizen::Base::Object
129 * This is the default constructor for this class.
133 FileAttributes(void);
136 * This destructor overrides Tizen::Base::Object::~Object().
140 virtual ~FileAttributes(void);
143 * Copying of objects using this copy constructor is allowed.
147 * @param[in] rhs An instance of %FileAttributes
149 FileAttributes(const FileAttributes& rhs);
152 * Assigns the value of the specified instance to the current instance of %FileAttributes.
156 * @return The reference of this instance
157 * @param[in] rhs An instance of %FileAttributes
159 FileAttributes& operator =(const FileAttributes& rhs);
162 * Compares the specified instance of Object to the calling instance of %FileAttributes.
166 * @return @c true if the values of the specified instance equals the values of the current instance, @n
168 * @param[in] object The object to compare with the current instance
170 virtual bool Equals(const Tizen::Base::Object& object) const;
173 * Gets the hash value of the current instance.
177 * @return An integer value indicating the hash value of the current instance
179 virtual int GetHashCode(void) const;
182 * Gets the file size.
186 * @return The file size in bytes
188 long long GetFileSize(void) const;
191 * Checks whether the current file is a directory.
195 * @return @c true if the file is a directory, @n
198 bool IsDirectory(void) const;
201 * Checks whether the file has a hidden attribute.
205 * @return @c true if the file has a hidden attribute, @n
208 bool IsHidden(void) const;
211 * Checks whether the file has a read-only attribute.
215 * @return @c true if the file has a read-only attribute, @n
218 bool IsReadOnly(void) const;
221 * Gets the date and time of the last modification to the file.
225 * @return The date and time of the last modification to the file
227 Tizen::Base::DateTime GetDateTime(void) const;
230 * Gets the date and time of the last modification to the file.
234 * @return The date and time of the last modification to the file
236 Tizen::Base::DateTime GetLastModifiedTime(void) const;
239 class _FileAttributesImpl* __pFileAttributesImpl;
241 friend class _FileAttributesImpl;
247 #endif //_FIO_FILE_ATTRIBUTES_H_