1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * @brief Implementation for DirItem routines
10 #include "UnicodeString.h"
16 * @brief Set filename and path for the item.
17 * @param [in] fullpath Full path to file to set to item.
19 void DirItem::SetFile(const String &fullPath)
21 String ext, filename2, path2;
22 paths::SplitFilename(fullPath, &path2, &filename2, &ext);
30 * @brief Get the full path of the item.
33 String DirItem::GetFile() const
35 return paths::ConcatPath(path.get(), filename.get());
39 * @brief Update fileinfo from given file.
40 * This function updates file's information from given item. Function
41 * does not set filename and path.
42 * @param [in] sFilePath Full path to file/directory to update
43 * @return true if information was updated (item was found).
45 bool DirItem::Update(const String &sFilePath)
49 size = DirItem::FILE_SIZE_NONE;
53 if (!sFilePath.empty())
57 TFile file(sFilePath);
59 mtime = file.getLastModified();
60 // There can be files without modification date.
61 // Then we must use creation date. Of course we assume
62 // creation date then exists...
64 mtime = file.created();
66 // No size for directory ( size remains as -1)
67 if (!file.isDirectory())
68 size = file.getSize();
70 flags.attributes = GetFileAttributes(file.wpath().c_str());
82 * @brief Clears FileInfo data.
84 /*void DirItem::Clear()
92 * @brief Clears FileInfo data except path/filename.
94 void DirItem::ClearPartial()
98 size = DirItem::FILE_SIZE_NONE;