Jump to content

FileSystem::GetFileSize allways return 0 it's a bug? or my mistake?


Recommended Posts

Posted

Hi,

 

System::Print(Filesystem::GetFileSize("steam_appid.txt"));

 

return always 0;

 

System::Print(FileSystem::GetFileType("steam_appid.txt"));

 

but return 1 by GetFileType so the file is still there ?

 

have the problem with each file.

 

it's a bug? or my mistake?

 

working under Windows. 7 and c++.

 

Does anyone have the same problem?

 

thanks norbert

Posted

seems to crash for me in Lua. haven't tried it in C++ yet.

 

//Edit:

 

tested a bit more.

using

local path = "testfile.txt"

System:Print(FileSystem:GetFileSize(path))

 

crashes.

 

using

local path = "testfile.txt"

System:Print("size: "..FileSystem:GetFileSize(path))

 

prints "size: 0"

 

not sure why it crashes the other time.

Posted

it looks like a bug, honestly.

 

This works, though - just use it the same way:

class FS : public FileSystem
{
FS() : FileSystem()	{}

public:
static int GetFileSize(const std::string& path)
{
	std::string file = RealPath(path);

	struct stat filestat;
	stat(&path[0], &filestat);
	return static_cast<int>(filestat.st_size);
}
};

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...