From 1fd98d9f862b831f80f1ba4dcedf0c17d534bccb Mon Sep 17 00:00:00 2001 From: Johny Mattsson Date: Tue, 12 Jan 2016 17:53:45 +1100 Subject: [PATCH] Add file.fscfg() command for fs location + size. --- app/modules/file.c | 8 ++++++++ docs/en/modules/file.md | 21 ++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/app/modules/file.c b/app/modules/file.c index f588bfa5..0c88acf6 100644 --- a/app/modules/file.c +++ b/app/modules/file.c @@ -307,6 +307,13 @@ static int file_writeline( lua_State* L ) return 1; } +static int file_fscfg (lua_State *L) +{ + lua_pushinteger (L, fs.cfg.phys_addr); + lua_pushinteger (L, fs.cfg.phys_size); + return 2; +} + // Module function map static const LUA_REG_TYPE file_map[] = { { LSTRKEY( "list" ), LFUNCVAL( file_list ) }, @@ -323,6 +330,7 @@ static const LUA_REG_TYPE file_map[] = { { LSTRKEY( "flush" ), LFUNCVAL( file_flush ) }, { LSTRKEY( "rename" ), LFUNCVAL( file_rename ) }, { LSTRKEY( "fsinfo" ), LFUNCVAL( file_fsinfo ) }, + { LSTRKEY( "fscfg" ), LFUNCVAL( file_fscfg ) }, { LSTRKEY( "exists" ), LFUNCVAL( file_exists ) }, #endif { LNILKEY, LNILVAL } diff --git a/docs/en/modules/file.md b/docs/en/modules/file.md index 9c1ed9eb..d945f61c 100644 --- a/docs/en/modules/file.md +++ b/docs/en/modules/file.md @@ -99,6 +99,25 @@ none #### See also [`file.remove()`](#fileremove) +## file.fscfg () + +Returns the flash address and physical size of the file system area, in bytes. + +#### Syntax +`file.fscfg()` + +#### Parameters +none + +#### Returns +- `flash address` (number) +- `size` (number) + +#### Example +```lua +print(string.format("0x%x", file.fscfg())) +``` + ## file.fsinfo() Return size information for the file system, in bytes. @@ -356,4 +375,4 @@ file.close() #### See also - [`file.open()`](#fileopen) -- [`file.readline()`](#filereadline) \ No newline at end of file +- [`file.readline()`](#filereadline)