]>
cygwin.com Git - cygwin-apps/setup.git/blob - find.cc
2 * Copyright (c) 2002, Robert Collins.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * A copy of the GNU General Public License can be found at
12 * Written by DJ Delorie <dj@cygnus.com>
13 * Rewritten by Robert Collins <rbtcollins@hotmail.com>
17 /* The purpose of this file is to doa recursive find on a given
18 directory, calling a given function for each file found. */
21 static const char *cvsid
=
32 #include "FindVisitor.h"
35 Find::Find(String
const &starting_dir
) : _start_dir (starting_dir
), h(INVALID_HANDLE_VALUE
)
41 if (h
!= INVALID_HANDLE_VALUE
&& h
)
46 Find::accept (FindVisitor
&aVisitor
)
49 if (_start_dir
.size() > _MAX_PATH
)
50 throw new length_error ("starting dir longer than _MAX_PATH");
52 h
= FindFirstFile ((_start_dir
+ "/*").cstr_oneuse(), &wfd
);
54 if (h
== INVALID_HANDLE_VALUE
)
57 String basePath
= _start_dir
+ "/";
61 if (strcmp (wfd
.cFileName
, ".") == 0
62 || strcmp (wfd
.cFileName
, "..") == 0)
65 /* TODO: make a non-win32 file and dir info class and have that as the
68 if (wfd
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
69 aVisitor
.visitDirectory (basePath
, &wfd
);
71 aVisitor
.visitFile (basePath
, &wfd
);
73 while (FindNextFile (h
, &wfd
));
This page took 0.036078 seconds and 5 git commands to generate.