Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
directory.cpp
Package: celestia-1.6.0.tar.gz [view]
Upload User: center1979
Upload Date: 2022-07-26
Package Size: 50633k
Code Size: 2k
Category:
OpenGL program
Development Platform:
Visual C++
- // directory.h
- //
- // Copyright (C) 2003, Chris Laurel <claurel@shatters.net>
- //
- // This program is free software; you can redistribute it and/or
- // modify it under the terms of the GNU General Public License
- // as published by the Free Software Foundation; either version 2
- // of the License, or (at your option) any later version.
- #include <iostream>
- #include "directory.h"
- using namespace std;
- bool Directory::enumFiles(EnumFilesHandler& handler, bool deep)
- {
- string filename;
- while (nextFile(filename))
- {
- // Skip all files beginning with a period, most importantly, . and ..
- if (filename[0] == '.')
- continue;
- // TODO: optimize this to avoid allocating so many strings
- string pathname = handler.getPath() + string("/") + filename;
- if (IsDirectory(pathname))
- {
- if (deep)
- {
- Directory* dir = OpenDirectory(pathname);
- bool cont = true;
- if (dir != NULL)
- {
- handler.pushDir(filename);
- cont = dir->enumFiles(handler, deep);
- handler.popDir();
- delete dir;
- }
- if (!cont)
- return false;
- }
- }
- else
- {
- if (!handler.process(filename))
- return false;
- }
- }
- return true;
- }
- EnumFilesHandler::EnumFilesHandler()
- {
- }
- void EnumFilesHandler::pushDir(const std::string& dirName)
- {
- if (dirStack.size() > 0)
- dirStack.push_back(dirStack.back() + string("/") + dirName);
- else
- dirStack.push_back(dirName);
- }
- void EnumFilesHandler::popDir()
- {
- dirStack.pop_back();
- }
- const string& EnumFilesHandler::getPath() const
- {
- // need this so we can return a non-temporary value:
- static const string emptyString("");
- if (dirStack.size() > 0)
- return dirStack.back();
- else
- return emptyString;
- }