From 83f094bb5acb19b37001e510517d19467a8d8396 Mon Sep 17 00:00:00 2001 From: Paul Kulchenko Date: Wed, 22 Jun 2022 22:13:24 -0700 Subject: [PATCH] Rename GetLastModified to GetAssetLastModified and IsCompressed to IsAssetCompressed --- tool/net/demo/redbean.lua | 4 ++-- tool/net/help.txt | 15 ++++++++++++--- tool/net/redbean.c | 11 ++++++----- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/tool/net/demo/redbean.lua b/tool/net/demo/redbean.lua index 6fe162d59..202db0d89 100644 --- a/tool/net/demo/redbean.lua +++ b/tool/net/demo/redbean.lua @@ -317,7 +317,7 @@ local function main() if not IsAcceptablePath(paths[i]) then Write(' [BLOCKED]') end - if not IsCompressed(paths[i]) then + if not IsAssetCompressed(paths[i]) then Write(' [UNCOMPRESSED]') end if (GetAssetMode(paths[i]) & 0xF000) == 0x4000 then @@ -325,7 +325,7 @@ local function main() end Write('
\r\n') Write('Modified: ') - Write(FormatHttpDateTime(GetLastModifiedTime(paths[i]))) + Write(FormatHttpDateTime(GetAssetLastModifiedTime(paths[i]))) Write('
\r\n') Write('Mode: ') Write("0%o" % {GetAssetMode(paths[i])}) diff --git a/tool/net/help.txt b/tool/net/help.txt index b71c9cbf0..e3cae084c 100644 --- a/tool/net/help.txt +++ b/tool/net/help.txt @@ -769,13 +769,21 @@ FUNCTIONS directory. Also available as GetComment (deprecated). + GetAssetLastModifiedTime(path:str) → seconds:number + Returns UNIX timestamp for modification time of a ZIP asset (or + local file if the -D flag is used). + If both a file and a ZIP asset are present, then the file is used. + Also available as GetLastModifiedTime (deprecated). + GetAssetMode(path:str) → int Returns UNIX-style octal mode for ZIP asset (or local file if the - -D flag is used) + -D flag is used). + If both a file and a ZIP asset are present, then the file is used. GetAssetSize(path:str) → int Returns byte size of uncompressed contents of ZIP asset (or local - file if the -D flag is used) + file if the -D flag is used). + If both a file and a ZIP asset are present, then the file is used. GetBody() → str Returns the request message body if present or an empty string. @@ -971,9 +979,10 @@ v See khttprepeatable.c. Those headers will not be folded. Standard Returns true if IP address is part of the localhost network (127.0.0.0/8). - IsCompressed(path:str) → bool + IsAssetCompressed(path:str) → bool Returns true if ZIP artifact at path is stored on disk using DEFLATE compression. + Also available as IsCompressed (deprecated). IndentLines(str[,int]) → str Adds spaces to beginnings of multiline string. If the int diff --git a/tool/net/redbean.c b/tool/net/redbean.c index c579461cb..8dd31572b 100644 --- a/tool/net/redbean.c +++ b/tool/net/redbean.c @@ -4841,7 +4841,7 @@ static int LuaGetAssetMode(lua_State *L) { return 1; } -static int LuaGetLastModifiedTime(lua_State *L) { +static int LuaGetAssetLastModifiedTime(lua_State *L) { size_t pathlen; struct Asset *a; const char *path; @@ -4879,7 +4879,7 @@ static int LuaGetAssetSize(lua_State *L) { return 1; } -static int LuaIsCompressed(lua_State *L) { +static int LuaIsAssetCompressed(lua_State *L) { size_t pathlen; struct Asset *a; const char *path; @@ -5033,6 +5033,7 @@ static const luaL_Reg kLuaFuncs[] = { {"FormatHttpDateTime", LuaFormatHttpDateTime}, // {"FormatIp", LuaFormatIp}, // {"GetAssetComment", LuaGetAssetComment}, // + {"GetAssetLastModifiedTime", LuaGetAssetLastModifiedTime}, // {"GetAssetMode", LuaGetAssetMode}, // {"GetAssetSize", LuaGetAssetSize}, // {"GetBody", LuaGetBody}, // @@ -5052,7 +5053,6 @@ static const luaL_Reg kLuaFuncs[] = { {"GetHostOs", LuaGetHostOs}, // {"GetHttpReason", LuaGetHttpReason}, // {"GetHttpVersion", LuaGetHttpVersion}, // - {"GetLastModifiedTime", LuaGetLastModifiedTime}, // {"GetLogLevel", LuaGetLogLevel}, // {"GetMethod", LuaGetMethod}, // {"GetMonospaceWidth", LuaGetMonospaceWidth}, // @@ -5079,7 +5079,7 @@ static const luaL_Reg kLuaFuncs[] = { {"IsAcceptablePath", LuaIsAcceptablePath}, // {"IsAcceptablePort", LuaIsAcceptablePort}, // {"IsClientUsingSsl", LuaIsClientUsingSsl}, // - {"IsCompressed", LuaIsCompressed}, // + {"IsAssetCompressed", LuaIsAssetCompressed}, // {"IsDaemon", LuaIsDaemon}, // {"IsHeaderRepeatable", LuaIsHeaderRepeatable}, // {"IsHiddenPath", LuaIsHiddenPath}, // @@ -5166,7 +5166,8 @@ static const luaL_Reg kLuaFuncs[] = { {"GetPayload", LuaGetBody}, // {"GetComment", LuaGetAssetComment}, // {"GetVersion", LuaGetHttpVersion}, // - + {"IsCompressed", LuaIsAssetCompressed}, // + {"GetLastModifiedTime", LuaGetAssetLastModifiedTime}, // }; static const luaL_Reg kLuaLibs[] = {