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.
20 * @brief This is the header file for the %DirEntry class.
22 * This header file contains the declarations of the %DirEntry class.
25 #ifndef _FIO_DIR_ENTRY_H_
26 #define _FIO_DIR_ENTRY_H_
28 #include <FBaseObject.h>
30 namespace Tizen { namespace Base
36 namespace Tizen { namespace Io
41 * @brief This class stores the information about each directory entry.
45 * @final This class is not intended for extension.
47 * The %DirEntry class stores the information about each directory entry.
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 * @see Tizen::Io::Directory
53 * @see Tizen::Io::File
55 * The following example demonstrates how to use the %DirEntry class.
62 using namespace Tizen::Base;
63 using namespace Tizen::Io;
67 String dirName(L"test");
69 DirEnumerator *pDirEnum = null;
71 Tizen::Base::DateTime dt;
75 r = dir.Construct(App::GetInstance()->GetAppDataPath() + dirName);
81 // Read all the directory entries
82 pDirEnum = dir.ReadN();
88 // Loop through all the directory entries
89 while (pDirEnum->MoveNext() == E_SUCCESS)
91 DirEntry dirEntry = pDirEnum->GetCurrentDirEntry();
93 // Get several properties of each directory entry.
94 name = dirEntry.GetName();
97 name += Long((long) dirEntry.GetFileSize()).ToString();
99 if (dirEntry.IsDirectory())
101 name += L", [directory]";
103 if (dirEntry.IsReadOnly())
105 name += L", [read-only]";
107 if (dirEntry.IsHidden())
109 name += L", [hidden]";
112 dt = dirEntry.GetDateTime();
115 name += dt.GetYear();
118 name += dt.GetMonth();
124 name += dt.GetHour();
127 name += dt.GetMinute();
129 name += L", second=";
130 name += dt.GetSecond();
132 // Print out message...
135 // Delete the enumerator
140 // The opened directory is closed automatically when the destructor of Directory class is invoked
153 class _OSP_EXPORT_ DirEntry
154 : public Tizen::Base::Object
159 * This destructor overrides Tizen::Base::Object::~Object().
163 virtual ~DirEntry(void);
166 * Copying of objects using this copy constructor is allowed.
170 * @param[in] rhs An instance of %DirEntry
172 DirEntry(const DirEntry& rhs);
175 * Assigns the value of the specified instance to the current instance of %DirEntry.
179 * @return A reference to the calling instance
180 * @param[in] rhs An instance of %DirEntry
182 DirEntry& operator =(const DirEntry& rhs);
185 * Compares the specified instance of Object to the calling instance of %DirEntry.
189 * @return @c true if the values of the specified instance equals the values of the current instance, @n
191 * @param[in] object The object to compare with the current instance
193 virtual bool Equals(const Object& object) const;
196 * Gets the hash value of the current instance.
200 * @return An integer value indicating the hash value of the current instance
202 virtual int GetHashCode(void) const;
205 * Gets the name of this directory entry.
209 * @return The name of this directory entry
211 const Tizen::Base::String GetName(void) const;
214 * Gets the file size of this directory entry.
218 * @return The file size of this directory entry
220 unsigned long GetFileSize(void) const;
223 * Checks whether the current %DirEntry instance is a directory.
227 * @return @c true if it is a directory, @n
230 bool IsDirectory(void) const;
233 * Checks whether a file has a hidden attribute.
237 * @return @c true if the file has a hidden attribute, @n
240 bool IsHidden(void) const;
243 * Checks whether a file has a read-only attribute.
247 * @return @c true if the file has a read-only attribute, @n
250 bool IsReadOnly(void) const;
253 * Gets the date and time of last modification of the directory entry.
257 * @return The date and time of last modification
259 Tizen::Base::DateTime GetDateTime(void) const;
263 * This default constructor is intentionally declared as private so that only the platform can create an instance.
269 class _DirEntryImpl* __pDirEntryImpl;
271 friend class _DirEntryImpl;
277 #endif // _FIO_DIR_ENTRY_H_