1 /////////////////////////////////////////////////////////////////////////////
3 // This program is free software; you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation; either version 2 of the License, or (at
6 // your option) any later version.
8 // This program is distributed in the hope that it will be useful, but
9 // WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 /////////////////////////////////////////////////////////////////////////////
20 * @brief Implementation for DirItem routines
26 #include "UnicodeString.h"
32 * @brief Convert file flags to string presentation.
33 * This function converts file flags to a string presentation that can be
35 * @return File flags as a string.
37 String FileFlags::ToString() const
40 if (attributes & FILE_ATTRIBUTE_READONLY)
42 if (attributes & FILE_ATTRIBUTE_HIDDEN)
44 if (attributes & FILE_ATTRIBUTE_SYSTEM)
46 if (attributes & FILE_ATTRIBUTE_ARCHIVE)
52 * @brief Set filename and path for the item.
53 * @param [in] fullpath Full path to file to set to item.
55 void DirItem::SetFile(const String &fullPath)
57 String ext, filename2, path2;
58 paths::SplitFilename(fullPath, &path2, &filename2, &ext);
66 * @brief Get the full path of the item.
69 String DirItem::GetFile() const
71 return paths::ConcatPath(path.get(), filename.get());
75 * @brief Update fileinfo from given file.
76 * This function updates file's information from given item. Function
77 * does not set filename and path.
78 * @param [in] sFilePath Full path to file/directory to update
79 * @return true if information was updated (item was found).
81 bool DirItem::Update(const String &sFilePath)
85 size = DirItem::FILE_SIZE_NONE;
89 if (!sFilePath.empty())
93 TFile file(sFilePath);
95 mtime = file.getLastModified();
96 // There can be files without modification date.
97 // Then we must use creation date. Of course we assume
98 // creation date then exists...
100 mtime = file.created();
102 // No size for directory ( size remains as -1)
103 if (!file.isDirectory())
104 size = file.getSize();
106 flags.attributes = GetFileAttributes(TFile(sFilePath).wpath().c_str());
118 * @brief Clears FileInfo data.
120 /*void DirItem::Clear()
128 * @brief Clears FileInfo data except path/filename.
130 void DirItem::ClearPartial()
134 size = DirItem::FILE_SIZE_NONE;