git repos / blockattack-game

blame: source/code/listFiles.h

normal view · raw

89c4a3a6 sago007 2008-08-29 14:32 1
/*
c53e6443 sago007 2012-04-17 11:04 2
===========================================================================
c53e6443 sago007 2012-04-17 11:04 3
blockattack - Block Attack - Rise of the Blocks
c53e6443 sago007 2012-04-17 11:04 4
Copyright (C) 2005-2012 Poul Sander
89c4a3a6 sago007 2008-08-29 14:32 5
c53e6443 sago007 2012-04-17 11:04 6
This program is free software: you can redistribute it and/or modify
c53e6443 sago007 2012-04-17 11:04 7
it under the terms of the GNU General Public License as published by
c53e6443 sago007 2012-04-17 11:04 8
the Free Software Foundation, either version 2 of the License, or
c53e6443 sago007 2012-04-17 11:04 9
(at your option) any later version.
89c4a3a6 sago007 2008-08-29 14:32 10
c53e6443 sago007 2012-04-17 11:04 11
This program is distributed in the hope that it will be useful,
c53e6443 sago007 2012-04-17 11:04 12
but WITHOUT ANY WARRANTY; without even the implied warranty of
c53e6443 sago007 2012-04-17 11:04 13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c53e6443 sago007 2012-04-17 11:04 14
GNU General Public License for more details.
89c4a3a6 sago007 2008-08-29 14:32 15
c53e6443 sago007 2012-04-17 11:04 16
You should have received a copy of the GNU General Public License
c53e6443 sago007 2012-04-17 11:04 17
along with this program.  If not, see http://www.gnu.org/licenses/
89c4a3a6 sago007 2008-08-29 14:32 18
c53e6443 sago007 2012-04-17 11:04 19
Source information and contacts persons can be found at
c53e6443 sago007 2012-04-17 11:04 20
http://blockattack.sf.net
c53e6443 sago007 2012-04-17 11:04 21
===========================================================================
89c4a3a6 sago007 2008-08-29 14:32 22
*/
89c4a3a6 sago007 2008-08-29 14:32 23
89c4a3a6 sago007 2008-08-29 14:32 24
//listFiles.h - List files in a given directory, 10 files at a time, at most 250 files
89c4a3a6 sago007 2008-08-29 14:32 25
#include <string.h>
89c4a3a6 sago007 2008-08-29 14:32 26
#include <iostream>
78d03b38 sago007 2008-11-13 19:56 27
#include <stdlib.h>
89c4a3a6 sago007 2008-08-29 14:32 28
#if defined(_WIN32)
89c4a3a6 sago007 2008-08-29 14:32 29
#include <windows.h>
89c4a3a6 sago007 2008-08-29 14:32 30
#elif defined(__unix__)
89c4a3a6 sago007 2008-08-29 14:32 31
#include	<dirent.h>
89c4a3a6 sago007 2008-08-29 14:32 32
#endif
89c4a3a6 sago007 2008-08-29 14:32 33
#include <string>
89c4a3a6 sago007 2008-08-29 14:32 34
#include <vector>
89c4a3a6 sago007 2008-08-29 14:32 35
89c4a3a6 sago007 2008-08-29 14:32 36
#if defined (_WIN32)
89c4a3a6 sago007 2008-08-29 14:32 37
#define FIRST_FILE 2
89c4a3a6 sago007 2008-08-29 14:32 38
#else
f876e3cb sago007 2008-11-14 21:21 39
#define FIRST_FILE 1
89c4a3a6 sago007 2008-08-29 14:32 40
#endif
89c4a3a6 sago007 2008-08-29 14:32 41
89c4a3a6 sago007 2008-08-29 14:32 42
class ListFiles
89c4a3a6 sago007 2008-08-29 14:32 43
{
89c4a3a6 sago007 2008-08-29 14:32 44
private:
c53e6443 sago007 2012-04-17 11:04 45
	int startFileNr;   //The first fileto belisted
8ec2d339 sago007 2015-11-24 20:27 46
	std::vector<std::string> filenames;
89c4a3a6 sago007 2008-08-29 14:32 47
#if defined(_WIN32)
c53e6443 sago007 2012-04-17 11:04 48
	WIN32_FIND_DATA FindFileData;
c53e6443 sago007 2012-04-17 11:04 49
	HANDLE hFind;
89c4a3a6 sago007 2008-08-29 14:32 50
#endif
8ec2d339 sago007 2015-11-24 20:27 51
	bool isInList(const std::string& name); //The name is already in the list
89c4a3a6 sago007 2008-08-29 14:32 52
public:
c53e6443 sago007 2012-04-17 11:04 53
	//ListFiles();
c53e6443 sago007 2012-04-17 11:04 54
	//~ListFiles();
8ec2d339 sago007 2015-11-24 20:27 55
	void setDirectory(const std::string& dictory); //Find file in BlockAttack folder
8ec2d339 sago007 2015-11-24 20:27 56
	void setDirectory2(const std::string& dictory); //Second directory we also look in
c53e6443 sago007 2012-04-17 11:04 57
	//void setDirecctoryInHome(string dictory); //Find files in home folder (it should work...)
90e6c797 sago007 2015-11-22 21:46 58
	std::string getFileName(int);      //Returns the filename of a file
c53e6443 sago007 2012-04-17 11:04 59
	bool fileExists(int);
c53e6443 sago007 2012-04-17 11:04 60
	void forward();  //inclease startFile by 10
c53e6443 sago007 2012-04-17 11:04 61
	void back();      //decrease startFile by 10
90e6c797 sago007 2015-11-22 21:46 62
	std::string getRandom(); //Return the name of a random file in the directory, empty if none
89c4a3a6 sago007 2008-08-29 14:32 63
};
1970-01-01 00:00 64