Actually stop iterating if retval != INFO::OK. Also fix comments.

This was SVN commit r16900.
This commit is contained in:
leper 2015-07-30 21:50:58 +00:00
parent 15a4c813d6
commit c5aad60776
2 changed files with 11 additions and 9 deletions

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2010 Wildfire Games
/* Copyright (c) 2015 Wildfire Games
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -25,14 +25,15 @@
*/
#include "precompiled.h"
#include "lib/file/vfs/vfs_util.h"
#include <queue>
#include <cstring>
#include <cstdio>
#include <cstring>
#include <queue>
#include "lib/sysdep/filesystem.h"
#include "lib/regex.h"
#include "lib/sysdep/filesystem.h"
namespace vfs {
@ -58,7 +59,8 @@ Status GetPathnames(const PIVFS& fs, const VfsPath& path, const wchar_t* filter,
Status ForEachFile(const PIVFS& fs, const VfsPath& startPath, FileCallback cb, uintptr_t cbData, const wchar_t* pattern, size_t flags)
{
// (declare here to avoid reallocations)
CFileInfos files; DirectoryNames subdirectoryNames;
CFileInfos files;
DirectoryNames subdirectoryNames;
// (a FIFO queue is more efficient than recursion because it uses less
// stack space and avoids seeks due to breadth-first traversal.)
@ -77,7 +79,7 @@ Status ForEachFile(const PIVFS& fs, const VfsPath& startPath, FileCallback cb, u
continue;
const VfsPath pathname(path / fileInfo.Name()); // (CFileInfo only stores the name)
cb(pathname, fileInfo, cbData);
RETURN_STATUS_IF_ERR(cb(pathname, fileInfo, cbData));
}
if(!(flags & DIR_RECURSIVE))

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2010 Wildfire Games
/* Copyright (c) 2015 Wildfire Games
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -40,7 +40,7 @@ extern Status GetPathnames(const PIVFS& fs, const VfsPath& path, const wchar_t*
* @param pathname full pathname (since CFileInfo only gives the name).
* @param fileInfo file information
* @param cbData user-specified context
* @return INFO::CONTINUE on success; any other value will immediately
* @return INFO::OK on success; any other value will immediately
* be returned to the caller (no more calls will be forthcoming).
*
* CAVEAT: pathname and fileInfo are only valid until the function
@ -58,7 +58,7 @@ enum DirFlags
*
* @param fs
* @param path
* @param cb See DirCallback
* @param cb @ref FileCallback
* @param cbData
* @param pattern that file names must match. '*' and '&' wildcards
* are allowed. 0 matches everything.