mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-30 10:06:35 +03:00
Added cTexturePacker. Utility class to create texture atlas and save the subtextures as shapes.
Added cTextureGroupLoader. Utility class to load the texture atlas saved shapes ( sync and async ). Added cTexturePackerNode and cTexturePackerTex, both are helpers to create the texture atlas, and not visibles to the end user. Added some helpers functions for file path management. Added some new functions for cImage. scaling, resize, thumnails, copy image into image, and some others, and moved some cTexture functions to cImage. Added stbi_info support for BMP,PSD,HDR,PIC in stb_image. Added Progress() function to cResourceLoader, to know the current loading progress in percent ( 0%-100% ). Added api calls to some classes. But i'm still looking how to work with DLL. Modified some details in cTimer and cTimeElapsed. The code was only tested on linux, so, still need some checking, but, it's a lot of code, so i'll commit it and fix bugs if it's necessary.
This commit is contained in:
@@ -16,9 +16,8 @@
|
||||
|
||||
#if EE_PLATFORM == EE_PLATFORM_WIN32
|
||||
#include <direct.h>
|
||||
#else
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
|
||||
#if EE_PLATFORM == EE_PLATFORM_WIN32
|
||||
#include <sys/utime.h>
|
||||
@@ -32,14 +31,9 @@
|
||||
|
||||
namespace EE { namespace Utils {
|
||||
|
||||
bool FileExists(const std::string& filepath) {
|
||||
std::fstream fs;
|
||||
fs.open( filepath.c_str(), std::ios::in );
|
||||
if( fs.is_open() ) {
|
||||
fs.close();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
bool FileExists( const std::string& Filepath ) {
|
||||
struct stat st;
|
||||
return ( stat( Filepath.c_str(), &st ) == 0 );
|
||||
}
|
||||
|
||||
Uint32 eeGetTicks() {
|
||||
@@ -197,13 +191,13 @@ std::vector<std::string> FilesGetInPath( const std::string& path ) {
|
||||
}
|
||||
|
||||
Uint32 FileSize( const std::string& Filepath ) {
|
||||
std::ifstream f;
|
||||
f.open(Filepath.c_str(), std::ios_base::binary | std::ios_base::in);
|
||||
if (!f.good() || f.eof() || !f.is_open()) { return 0; }
|
||||
f.seekg(0, std::ios_base::beg);
|
||||
std::ifstream::pos_type begin_pos = f.tellg();
|
||||
f.seekg(0, std::ios_base::end);
|
||||
return static_cast<Uint32>(f.tellg() - begin_pos);
|
||||
struct stat st;
|
||||
int res = stat( Filepath.c_str(), &st );
|
||||
|
||||
if ( 0 == res )
|
||||
return st.st_size;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
eeDouble GetSystemTime() {
|
||||
@@ -337,6 +331,18 @@ std::string FileExtension( const std::string& filepath, const bool& lowerExt ) {
|
||||
return tstr;
|
||||
}
|
||||
|
||||
std::string FileRemoveExtension( const std::string& filepath ) {
|
||||
return filepath.substr( 0, filepath.find_last_of(".") );
|
||||
}
|
||||
|
||||
std::string FileNameFromPath( const std::string& filepath ) {
|
||||
return filepath.substr( filepath.find_last_of("/\\") + 1 );
|
||||
}
|
||||
|
||||
std::string FileRemoveFileName( const std::string& filepath ) {
|
||||
return filepath.substr( 0, filepath.find_last_of("/\\") + 1 );
|
||||
}
|
||||
|
||||
eeInt GetNumCPUs() {
|
||||
eeInt nprocs = -1;
|
||||
|
||||
@@ -389,4 +395,14 @@ bool FileWrite( const std::string& filepath, const std::vector<Uint8>& data ) {
|
||||
return FileWrite( filepath, reinterpret_cast<const Uint8*> ( &data[0] ), (Uint32)data.size() );
|
||||
}
|
||||
|
||||
Uint32 FileGetModificationDate( const std::string& Filepath ) {
|
||||
struct stat st;
|
||||
int res = stat( Filepath.c_str(), &st );
|
||||
|
||||
if ( 0 == res )
|
||||
return st.st_mtime;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user