git repos / blockattack-game

blame: source/code/listFiles.h

normal view · raw

89c4a3a6 sago007 2008-08-29 14:32 1
/*
89c4a3a6 sago007 2008-08-29 14:32 2
listFiles.h
89c4a3a6 sago007 2008-08-29 14:32 3
Copyright (C) 2005 Poul Sander
89c4a3a6 sago007 2008-08-29 14:32 4
89c4a3a6 sago007 2008-08-29 14:32 5
    This program is free software; you can redistribute it and/or modify
89c4a3a6 sago007 2008-08-29 14:32 6
    it under the terms of the GNU General Public License as published by
89c4a3a6 sago007 2008-08-29 14:32 7
    the Free Software Foundation; either version 2 of the License, or
89c4a3a6 sago007 2008-08-29 14:32 8
    (at your option) any later version.
89c4a3a6 sago007 2008-08-29 14:32 9
89c4a3a6 sago007 2008-08-29 14:32 10
    This program is distributed in the hope that it will be useful,
89c4a3a6 sago007 2008-08-29 14:32 11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
89c4a3a6 sago007 2008-08-29 14:32 12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
89c4a3a6 sago007 2008-08-29 14:32 13
    GNU General Public License for more details.
89c4a3a6 sago007 2008-08-29 14:32 14
89c4a3a6 sago007 2008-08-29 14:32 15
    You should have received a copy of the GNU General Public License
89c4a3a6 sago007 2008-08-29 14:32 16
    along with this program; if not, write to the Free Software
89c4a3a6 sago007 2008-08-29 14:32 17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
89c4a3a6 sago007 2008-08-29 14:32 18
89c4a3a6 sago007 2008-08-29 14:32 19
    Poul Sander
89c4a3a6 sago007 2008-08-29 14:32 20
    R�veh�jvej 36, V. 1111
89c4a3a6 sago007 2008-08-29 14:32 21
    2800 Kgs. Lyngby
89c4a3a6 sago007 2008-08-29 14:32 22
    DENMARK
89c4a3a6 sago007 2008-08-29 14:32 23
    blockattack@poulsander.com
89c4a3a6 sago007 2008-08-29 14:32 24
*/
89c4a3a6 sago007 2008-08-29 14:32 25
89c4a3a6 sago007 2008-08-29 14:32 26
//listFiles.h - List files in a given directory, 10 files at a time, at most 250 files
89c4a3a6 sago007 2008-08-29 14:32 27
#include <string.h>
89c4a3a6 sago007 2008-08-29 14:32 28
#include <iostream>
78d03b38 sago007 2008-11-13 19:56 29
#include <stdlib.h>
89c4a3a6 sago007 2008-08-29 14:32 30
#if defined(_WIN32)
89c4a3a6 sago007 2008-08-29 14:32 31
#include <windows.h>
89c4a3a6 sago007 2008-08-29 14:32 32
#elif defined(__unix__)
89c4a3a6 sago007 2008-08-29 14:32 33
#include	<dirent.h>
89c4a3a6 sago007 2008-08-29 14:32 34
#endif
89c4a3a6 sago007 2008-08-29 14:32 35
#include <string>
89c4a3a6 sago007 2008-08-29 14:32 36
#include <vector>
89c4a3a6 sago007 2008-08-29 14:32 37
89c4a3a6 sago007 2008-08-29 14:32 38
#define MAX_NR_OF_FILES 253
89c4a3a6 sago007 2008-08-29 14:32 39
#if defined (_WIN32)
89c4a3a6 sago007 2008-08-29 14:32 40
#define FIRST_FILE 2
89c4a3a6 sago007 2008-08-29 14:32 41
#else
f876e3cb sago007 2008-11-14 21:21 42
#define FIRST_FILE 1
89c4a3a6 sago007 2008-08-29 14:32 43
#endif
89c4a3a6 sago007 2008-08-29 14:32 44
89c4a3a6 sago007 2008-08-29 14:32 45
using namespace std;
89c4a3a6 sago007 2008-08-29 14:32 46
89c4a3a6 sago007 2008-08-29 14:32 47
class ListFiles
89c4a3a6 sago007 2008-08-29 14:32 48
{
89c4a3a6 sago007 2008-08-29 14:32 49
private:
89c4a3a6 sago007 2008-08-29 14:32 50
    int startFileNr;   //The first fileto belisted
89c4a3a6 sago007 2008-08-29 14:32 51
    string filenames[MAX_NR_OF_FILES];
89c4a3a6 sago007 2008-08-29 14:32 52
    int nrOfFiles;
89c4a3a6 sago007 2008-08-29 14:32 53
#if defined(_WIN32)
89c4a3a6 sago007 2008-08-29 14:32 54
    WIN32_FIND_DATA FindFileData;
89c4a3a6 sago007 2008-08-29 14:32 55
    HANDLE hFind;
89c4a3a6 sago007 2008-08-29 14:32 56
#endif
89c4a3a6 sago007 2008-08-29 14:32 57
    bool isInList(string name); //The name is already in the list
89c4a3a6 sago007 2008-08-29 14:32 58
public:
89c4a3a6 sago007 2008-08-29 14:32 59
    //ListFiles();
89c4a3a6 sago007 2008-08-29 14:32 60
    //~ListFiles();
89c4a3a6 sago007 2008-08-29 14:32 61
    void setDirectory(string dictory); //Find file in BlockAttack folder
89c4a3a6 sago007 2008-08-29 14:32 62
    void setDirectory2(string dictory); //Second directory we also look in
89c4a3a6 sago007 2008-08-29 14:32 63
    //void setDirecctoryInHome(string dictory); //Find files in home folder (it should work...)
89c4a3a6 sago007 2008-08-29 14:32 64
    string getFileName(int);      //Returns the filename of a file
89c4a3a6 sago007 2008-08-29 14:32 65
    bool fileExists(int);
89c4a3a6 sago007 2008-08-29 14:32 66
    void forward();  //inclease startFile by 10
89c4a3a6 sago007 2008-08-29 14:32 67
    void back();      //decrease startFile by 10
89c4a3a6 sago007 2008-08-29 14:32 68
    string getRandom(); //Return the name of a random file in the directory, empty if none
89c4a3a6 sago007 2008-08-29 14:32 69
};
1970-01-01 00:00 70