01-26-2012, 07:29 AM
01-26-2012, 09:50 PM
http://code.google.com/p/dolphin-emu/source/browse/Source/Core/Common/Src/FileUtil.h#152 is what you need, then.
01-27-2012, 11:32 AM
In GCVolume.cpp, is "u8* _pBuffer" a pointer to the desired output?
01-27-2012, 06:47 PM
Erm... idk, I have no idea what you want to do with the data that you've read, so it'd probably be a better idea to allocate your own buffer and do some stuff with it :/ (don't forget to free the buffer later again).
01-28-2012, 06:10 AM
(01-27-2012, 06:47 PM)neobrain Wrote: [ -> ]Erm... idk, I have no idea what you want to do with the data that you've read, so it'd probably be a better idea to allocate your own buffer and do some stuff with it :/ (don't forget to free the buffer later again).
Well, the same thing the other readers do. Just the source of the file will be in User/Load/Files/<game_id> instead of the ISO. The final copy location should be the same.
01-30-2012, 07:29 AM
Why doesn't this read function work? It always returns false because pFile is always null, even when the file is there. Why?
Code:
bool FileLoader::Read(std::string Filename, u8* out_buf)
{
if(!SConfig::GetInstance().m_LocalCoreStartupParameter.bLoadFiles)
return false;
size_t found=Filename.find_last_of("/");
std::string RealFilename=Filename.substr(found+1);
if(!IsFilePresent(RealFilename))
{
return false;
}
FILE* pFile;
pFile = fopen(RealFilename.c_str(),"rb");
if(!pFile)
{
return false;
}
fread(out_buf,1,1000000000,pFile);
return true;
}01-30-2012, 07:40 AM
Doesn't wx have its own methods of reading files? Just wondering why you don't use those...
http://wiki.wxwidgets.org/Reading_text_from_a_file
http://wiki.wxwidgets.org/Reading_text_from_a_file
01-30-2012, 08:11 AM
(01-30-2012, 07:29 AM)HawaiianPunch Wrote: [ -> ]Why doesn't this read function work? It always returns false because pFile is always null, even when the file is there. Why?
You sure the function is returning false because pFile is always NULL? Did you check to see if the two other if statements aren't the ones returning false? If those statements are fine, it could just be that fopen can't open the file even if it exists (e.g. permission problems, file in use by another program, etc). Also, be sure to verity the value of RealFilename.c_str() with your own eyes by printing it out.
01-30-2012, 08:15 AM
(01-30-2012, 08:11 AM)Shonumi Wrote: [ -> ](01-30-2012, 07:29 AM)HawaiianPunch Wrote: [ -> ]Why doesn't this read function work? It always returns false because pFile is always null, even when the file is there. Why?
You sure the function is returning false because pFile is always NULL? Did you check to see if the two other if statements aren't the ones returning false? If those statements are fine, it could just be that fopen can't open the file even if it exists. Also, be sure to verity the value of RealFilename.c_str() with your own eyes by printing it out.
Yep. I had some panic alerts before I pasted this in and they were triggering, so I know it was null.
Also, I printed RealFile.c_str() and it printed the correct file.
Am I using fopen correctly? Should I use "rb" or just "r"?
01-30-2012, 08:26 AM
(01-30-2012, 07:40 AM)scummos Wrote: [ -> ]Doesn't wx have its own methods of reading files? Just wondering why you don't use those...wx functions are not used in Core
http://wiki.wxwidgets.org/Reading_text_from_a_file
i havent looked at the rest of your code, but IsFilePresent checks a specific directory right? and realfilename doesnt include that directory.
fopen will use the cwd (which shouldn't be changed from the directory that dolphin.exe is located in) which doesnt have the file
use a relative path from the dolphin root dir IE "./User/foo/bar.baz" instead of what i suspect reafilename is "foo.bar"
also use these functions for fileio
(01-26-2012, 09:50 PM)neobrain Wrote: [ -> ]http://code.google.com/p/dolphin-emu/source/browse/Source/Core/Common/Src/FileUtil.h#152 is what you need, then.