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.
19 * @brief This is the header file for the %DirEntry class.
21 * This header file contains the declarations of the %DirEntry class.
24 #ifndef _FIO_DIR_ENTRY_H_
25 #define _FIO_DIR_ENTRY_H_
27 #include <FBaseObject.h>
29 namespace Tizen { namespace Base
35 namespace Tizen { namespace Io
40 * @brief This class stores the information about each directory entry.
44 * @final This class is not intended for extension.
46 * The %DirEntry class stores the information about each directory entry.
48 * For more information on the class features,
49 * see <a href="../org.tizen.native.appprogramming/html/guide/io/io_namespace.htm">Io Guide</a>.
51 * @see Tizen::Io::Directory
52 * @see Tizen::Io::File
54 * The following example demonstrates how to use the %DirEntry class.
61 using namespace Tizen::Base;
62 using namespace Tizen::Io;
66 String dirName(L"test");
68 DirEnumerator *pDirEnum = null;
70 Tizen::Base::DateTime dt;
74 r = dir.Construct(App::GetInstance()->GetAppDataPath() + dirName);
80 // Read all the directory entries
81 pDirEnum = dir.ReadN();
87 // Loop through all the directory entries
88 while (pDirEnum->MoveNext() == E_SUCCESS)
90 DirEntry dirEntry = pDirEnum->GetCurrentDirEntry();
92 // Get several properties of each directory entry.
93 name = dirEntry.GetName();
96 name += Long((long) dirEntry.GetFileSize()).ToString();
98 if (dirEntry.IsDirectory())
100 name += L", [directory]";
102 if (dirEntry.IsReadOnly())
104 name += L", [read-only]";
106 if (dirEntry.IsHidden())
108 name += L", [hidden]";
111 dt = dirEntry.GetDateTime();
114 name += dt.GetYear();
117 name += dt.GetMonth();
123 name += dt.GetHour();
126 name += dt.GetMinute();
128 name += L", second=";
129 name += dt.GetSecond();
131 // Print out message...
134 // Delete the enumerator
139 // The opened directory is closed automatically when the destructor of Directory class is invoked
152 class _OSP_EXPORT_ DirEntry
153 : public Tizen::Base::Object
158 * This destructor overrides Tizen::Base::Object::~Object().
162 virtual ~DirEntry(void);
165 * Copying of objects using this copy constructor is allowed.
169 * @param[in] rhs An instance of %DirEntry
171 DirEntry(const DirEntry& rhs);
174 * Assigns the value of the specified instance to the current instance of %DirEntry.
178 * @return A reference to the calling instance
179 * @param[in] rhs An instance of %DirEntry
181 DirEntry& operator =(const DirEntry& rhs);
184 * Compares the specified instance of Object to the calling instance of %DirEntry.
188 * @return @c true if the values of the specified instance equals the values of the current instance, @n
190 * @param[in] object The object to compare with the current instance
192 virtual bool Equals(const Object& object) const;
195 * Gets the hash value of the current instance.
199 * @return An integer value indicating the hash value of the current instance
201 virtual int GetHashCode(void) const;
204 * Gets the name of this directory entry.
208 * @return The name of this directory entry
210 const Tizen::Base::String GetName(void) const;
213 * Gets the file size of this directory entry.
217 * @return The file size of this directory entry
219 unsigned long GetFileSize(void) const;
222 * Checks whether the current %DirEntry instance is a directory.
226 * @return @c true if it is a directory, @n
229 bool IsDirectory(void) const;
232 * Checks whether a file has a hidden attribute.
236 * @return @c true if the file has a hidden attribute, @n
239 bool IsHidden(void) const;
242 * Checks whether a file has a read-only attribute.
246 * @return @c true if the file has a read-only attribute, @n
249 bool IsReadOnly(void) const;
252 * Gets the date and time of the last modification of the directory entry.
256 * @return The date and time of the last modification
258 Tizen::Base::DateTime GetDateTime(void) const;
262 * This default constructor is intentionally declared as private so that only the platform can create an instance.
268 class _DirEntryImpl* __pDirEntryImpl;
270 friend class _DirEntryImpl;
276 #endif // _FIO_DIR_ENTRY_H_