Changeset View
Standalone View
source/lib/file/vfs/vfs_util.h
/* Copyright (C) 2015 Wildfire Games. | /* Copyright (C) 2019 Wildfire Games. | ||||
* | * | ||||
* Permission is hereby granted, free of charge, to any person obtaining | * Permission is hereby granted, free of charge, to any person obtaining | ||||
* a copy of this software and associated documentation files (the | * a copy of this software and associated documentation files (the | ||||
* "Software"), to deal in the Software without restriction, including | * "Software"), to deal in the Software without restriction, including | ||||
* without limitation the rights to use, copy, modify, merge, publish, | * without limitation the rights to use, copy, modify, merge, publish, | ||||
* distribute, sublicense, and/or sell copies of the Software, and to | * distribute, sublicense, and/or sell copies of the Software, and to | ||||
* permit persons to whom the Software is furnished to do so, subject to | * permit persons to whom the Software is furnished to do so, subject to | ||||
* the following conditions: | * the following conditions: | ||||
Show All 17 Lines | |||||
#ifndef INCLUDED_VFS_UTIL | #ifndef INCLUDED_VFS_UTIL | ||||
#define INCLUDED_VFS_UTIL | #define INCLUDED_VFS_UTIL | ||||
#include "lib/os_path.h" | #include "lib/os_path.h" | ||||
#include "lib/file/vfs/vfs.h" | #include "lib/file/vfs/vfs.h" | ||||
namespace vfs { | namespace vfs { | ||||
extern Status GetPathnames(const PIVFS& fs, const VfsPath& path, const wchar_t* filter, VfsPaths& pathnames); | /** | ||||
* This returns the file and directory names in the given path that meet the given namepattern. | |||||
* Can sort by ASCI order, to ensure that the loading order of all files is predictable and platform-independent, | |||||
wraitii: ASCII | |||||
*/ | |||||
extern Status GetPathnames(const PIVFS& fs, const VfsPath& path, const wchar_t* filter, VfsPaths& pathnames, bool sorted); | |||||
vladislavbelovUnsubmitted Not Done Inline ActionsMaybe just sort? vladislavbelov: Maybe just `sort`? | |||||
elexisAuthorUnsubmitted Done Inline Actions(I wanted to avoid using names that we know exist in std::, so that there is no room for doubt when reading the if (sorted) line without reading the function header) elexis: (I wanted to avoid using names that we know exist in `std::`, so that there is no room for… | |||||
vladislavbelovUnsubmitted Not Done Inline ActionsNamespaces are for such purposes too: to have the same name for different types or variables. Also this function already contains used words: fs is declared as boost::filesystem, path is declared inside boost::filesystem and in std::filesystem since C++17. vladislavbelov: Namespaces are for such purposes too: to have the same name for different types or variables. | |||||
StanUnsubmitted Not Done Inline ActionsThe convention I learnt about boolean was more like IsSorted, HasValue, IsDead, could work here. Stan: The convention I learnt about boolean was more like IsSorted, HasValue, IsDead, could work here. | |||||
elexisAuthorUnsubmitted Done Inline ActionsBut path and fs existed already, sorted is a newly introduced one. So we have the choice between avoiding reuses and chosing them consciously. IMO if the second name isn't becoming ugly, avoiding ambiguity even if not syntactically problematic seems preferable on the subjective niceness scale? elexis: But `path` and `fs` existed already, `sorted` is a newly introduced one. So we have the choice… | |||||
vladislavbelovUnsubmitted Not Done Inline ActionsI don't mind, I just pointed out that the sort name isn't a problem. vladislavbelov: I don't mind, I just pointed out that the `sort` name isn't a problem. | |||||
/** | /** | ||||
* called for files in a directory. | * called for files in a directory. | ||||
* | * | ||||
* @param pathname full pathname (since CFileInfo only gives the name). | * @param pathname full pathname (since CFileInfo only gives the name). | ||||
* @param fileInfo file information | * @param fileInfo file information | ||||
* @param cbData user-specified context | * @param cbData user-specified context | ||||
* @return INFO::OK on success; any other value will immediately | * @return INFO::OK on success; any other value will immediately | ||||
▲ Show 20 Lines • Show All 59 Lines • Show Last 20 Lines |
ASCII