i've been continuing to code my file system class today and earlier i added the function FindFirstFile() to my constructor to give it a fndfile handler. when i tired to compile it said it couldn't convert string1 to type const char *. so i made string1 a const char* and then it said it couldn't convert it to a string! i fiddled around a bit and eventually all the errors dissapeared ( i even manged to replace the string by a function that returns a string. whoopee!). problem is i can't remember what i did (some crummy little detail probably)
all's well untill i tried to actually code the fileExist function. coded it, tried to compile and i got the same error from the constructor again! i tried reverting my code back to what it was and i still get the same error. there are two reasons
1) theres one little tiny piece of code that is breaking the whole thing
2) theres somthing in my IDE/compiler (dev c++/mingw) that i havent undestood which is making it not compile right
heres the code
file: fsystem.class.h
Code:
class C_fsystem
{
protected:
string SZ_fpath;
string SZ_fname;
string SZ_fexten;
HANDLE H_fileExists;
WIN32_FIND_DATA findFileData;
public:
void setPath(const string& TMP_buffer){ SZ_fpath = TMP_buffer;}
void setName(const string& TMP_buffer){ SZ_fname = TMP_buffer;}
void setExten(const string& TMP_buffer){ SZ_fexten = TMP_buffer;}
string fullName(void);
C_fsystem(const string& PARAM_path, const string& PARAM_name, const string& PARAM_exten);
int fileExists(void);
};
//this will output the full path
string C_fsystem::fullName(void)
{
string TMP_path = SZ_fpath;
TMP_path += SZ_fname;
TMP_path += ".";
TMP_path += SZ_fexten;
return(TMP_path);
}
C_fsystem::C_fsystem(const string& PARAM_path, const string& PARAM_name, const string& PARAM_exten)
{
SZ_fpath = PARAM_path;
SZ_fname = PARAM_name;
SZ_fexten = PARAM_exten;
string TMP_fullName = SZ_fpath+SZ_fname+"."+SZ_fexten;
H_fileExists = FindFirstFile(fullName(), findFileData);
}
int C_fsystem::fileExists(void)
{
return(0);
}
file: main.cpp
Code:
#define _WIN32_WINNT 0x0400
//standard includes
#include <iostream>
#include <string>
using namespace std;
#include <fstream.h>
#include <windows.h>
#include <shellapi.h>
#include <fsystem.class.h>
//main
int main()
{
C_fsystem myfile("D:\\my documents 2\\robin\\cpp sources\\terraserve\\", "main", "cpp");
cout<<myfile.fullName()<<": checking for this file...."<<endl;
cin.get();
exit(0);
}
compiler results:
In file included from d:\my documents 2\robin\cpp sources\terraserve\main.cpp:17:
D:\MYDOCU~1\ROBIN\CPPSOU~1\TERRAS~2\fsystem.class. h: In method `C_fsystem::C_fsystem(const string &, const string &, const string &)':
D:\MYDOCU~1\ROBIN\CPPSOU~1\TERRAS~2\fsystem.class. h:34: cannot convert `string()' from type `string' to type `const CHAR *'
much respect to you if you take the time to look though this, i know what its like