RL_GetFileLength.

This commit is contained in:
jussi
2022-12-10 18:47:45 +02:00
parent e1a85f898e
commit 7e61bffe5f
9 changed files with 34 additions and 5 deletions

9
API.md
View File

@@ -2003,6 +2003,15 @@ Check file extension ( Including point: .png, .wav )
--- ---
> length = RL_GetFileLength( string fileName )
Get file length in bytes ( NOTE: GetFileSize() conflicts with windows.h )
- Failure return false
- Success return int
---
> extension = RL_GetFileExtension( string fileName ) > extension = RL_GetFileExtension( string fileName )
Get pointer to extension for a filename string ( Includes dot: '.png' ) Get pointer to extension for a filename string ( Includes dot: '.png' )

View File

@@ -23,3 +23,4 @@ ADDED: Color lib.
FIXED: RL_DrawEllipse and RL_DrawEllipseLines expecting wrong arguments. FIXED: RL_DrawEllipse and RL_DrawEllipseLines expecting wrong arguments.
ADDED: RL_IsPathFile. ADDED: RL_IsPathFile.
ADDED: RL_SetMaterialShader. ADDED: RL_SetMaterialShader.
ADDED: RL_GetFileLength.

View File

@@ -7,4 +7,6 @@ Backlog {
* Text * Text
* Codepoints? * Codepoints?
* VR. * VR.
* Core.
* Compression/Encoding functionality.
} }

View File

@@ -201,7 +201,7 @@ function FileExplorer:fileSelect( file )
end end
function FileExplorer:openFile() function FileExplorer:openFile()
print( self.file ) print( self.file, RL_GetFileLength( self.file ) )
end end
function FileExplorer:updateFiles() function FileExplorer:updateFiles()

View File

@@ -23,7 +23,6 @@ function init()
local mPos = RL_GetMonitorPosition( monitor ) local mPos = RL_GetMonitorPosition( monitor )
local mSize = RL_GetMonitorSize( monitor ) local mSize = RL_GetMonitorSize( monitor )
local winSize = RL_GetWindowSize() local winSize = RL_GetWindowSize()
-- local winSize = { 1920, 1080 }
RL_SetWindowState( FLAG_WINDOW_RESIZABLE ) RL_SetWindowState( FLAG_WINDOW_RESIZABLE )
RL_SetWindowSize( winSize ) RL_SetWindowSize( winSize )

View File

@@ -51,7 +51,7 @@ Gui = {
_cells = {}, _cells = {},
_mousePos = Vec2:new( 0, 0 ), -- Last mouse position that was passed to Gui.process. _mousePos = Vec2:new( 0, 0 ), -- Last mouse position that was passed to Gui.process.
_inputElement = nil, _inputElement = nil, -- Element that has the input text item.
_inputItem = nil, -- Must be type Text. _inputItem = nil, -- Must be type Text.
} }
@@ -637,8 +637,6 @@ function Container:mouseScroll( v )
self:scroll( mousePos ) self:scroll( mousePos )
end end
-- //TODO Add this
function Container:isMouseOver( mousePosition ) function Container:isMouseOver( mousePosition )
local over = RL_CheckCollisionPointRec( mousePosition, self.bounds ) local over = RL_CheckCollisionPointRec( mousePosition, self.bounds )

View File

@@ -78,6 +78,7 @@ int lcoreGetBasePath( lua_State *L );
int lcoreFileExists( lua_State *L ); int lcoreFileExists( lua_State *L );
int lcoreDirectoryExists( lua_State *L ); int lcoreDirectoryExists( lua_State *L );
int lcoreIsFileExtension( lua_State *L ); int lcoreIsFileExtension( lua_State *L );
int lcoreGetFileLength( lua_State *L );
int lcoreGetFileExtension( lua_State *L ); int lcoreGetFileExtension( lua_State *L );
int lcoreGetFileName( lua_State *L ); int lcoreGetFileName( lua_State *L );
int lcoreGetFileNameWithoutExt( lua_State *L ); int lcoreGetFileNameWithoutExt( lua_State *L );

View File

@@ -2069,6 +2069,24 @@ int lcoreIsFileExtension( lua_State *L ) {
return 1; return 1;
} }
/*
> length = RL_GetFileLength( string fileName )
Get file length in bytes ( NOTE: GetFileSize() conflicts with windows.h )
- Failure return false
- Success return int
*/
int lcoreGetFileLength( lua_State *L ) {
if ( !lua_isstring( L, -1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GetFileLength( string fileName )" );
lua_pushboolean( L, false );
return 1;
}
lua_pushinteger( L, GetFileLength( lua_tostring( L, -1 ) ) );
return 1;
}
/* /*
> extension = RL_GetFileExtension( string fileName ) > extension = RL_GetFileExtension( string fileName )

View File

@@ -741,6 +741,7 @@ void luaRegister() {
lua_register( L, "RL_FileExists", lcoreFileExists ); lua_register( L, "RL_FileExists", lcoreFileExists );
lua_register( L, "RL_DirectoryExists", lcoreDirectoryExists ); lua_register( L, "RL_DirectoryExists", lcoreDirectoryExists );
lua_register( L, "RL_IsFileExtension", lcoreIsFileExtension ); lua_register( L, "RL_IsFileExtension", lcoreIsFileExtension );
lua_register( L, "RL_GetFileLength", lcoreGetFileLength );
lua_register( L, "RL_GetFileExtension", lcoreGetFileExtension ); lua_register( L, "RL_GetFileExtension", lcoreGetFileExtension );
lua_register( L, "RL_GetFileName", lcoreGetFileName ); lua_register( L, "RL_GetFileName", lcoreGetFileName );
lua_register( L, "RL_GetFileNameWithoutExt", lcoreGetFileNameWithoutExt ); lua_register( L, "RL_GetFileNameWithoutExt", lcoreGetFileNameWithoutExt );