删除部分内置函数
This commit is contained in:
@@ -1,54 +0,0 @@
|
||||
/*Software License
|
||||
|
||||
Copyright(C) 2024[liuyingjie]
|
||||
License Terms
|
||||
Usage Rights
|
||||
|
||||
Any individual or entity is free to use, copy, and distribute the binary form of this software without modification to the source code, without the need to disclose the source code.
|
||||
If the source code is modified, the modifications must be open - sourced under the same license.This means that the modifications must be disclosed and accompanied by a copy of this license.
|
||||
Future Versions Updates
|
||||
From this version onwards, all future releases will be governed by the terms of the latest version of the license.This license will automatically be nullified and replaced by the new version.
|
||||
Users must comply with the terms of the new license issued in future releases.
|
||||
Liability and Disclaimer
|
||||
This software is provided “as is”, without any express or implied warranties, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non - infringement.In no event shall the author or copyright holder be liable for any claims, damages, or other liabilities, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software.
|
||||
Contact Information
|
||||
If you have any questions, please contact us: 1585346868@qq.com Or visit our website fwlua.com.
|
||||
*/
|
||||
|
||||
#include "codec.h"
|
||||
#include "util/codec.h"
|
||||
std::string module::codec::url_de(const std::string& value)
|
||||
{
|
||||
return ylib::codec::url::de(value);
|
||||
}
|
||||
|
||||
std::string module::codec::url_en(const std::string& value)
|
||||
{
|
||||
return ylib::codec::url::en(value);
|
||||
}
|
||||
|
||||
std::string module::codec::to_utf8(const std::string& value)
|
||||
{
|
||||
return ylib::codec::to_utf8(value);
|
||||
}
|
||||
|
||||
std::string module::codec::to_gbk(const std::string& value)
|
||||
{
|
||||
return ylib::codec::to_gbk(value);
|
||||
}
|
||||
|
||||
std::string module::codec::md5(const std::string& value)
|
||||
{
|
||||
return ylib::codec::md5(value);
|
||||
}
|
||||
|
||||
void module::codec::regist(sol::state* lua)
|
||||
{
|
||||
lua->new_usertype<module::codec>("codec",
|
||||
"url_de", &module::codec::url_de,
|
||||
"url_en", &module::codec::url_en,
|
||||
"to_utf8", &module::codec::to_utf8,
|
||||
"to_gbk", &module::codec::to_gbk,
|
||||
"md5", &module::codec::md5
|
||||
);
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
#pragma once
|
||||
#include "sol/sol.hpp"
|
||||
#include "basemodule.h"
|
||||
|
||||
namespace module
|
||||
{
|
||||
/// <summary>
|
||||
/// 编解码
|
||||
/// </summary>
|
||||
class codec{
|
||||
public:
|
||||
/// <summary>
|
||||
/// URL解码
|
||||
/// </summary>
|
||||
static std::string url_de(const std::string& value);
|
||||
/// <summary>
|
||||
/// URL编码
|
||||
/// </summary>
|
||||
static std::string url_en(const std::string& value);
|
||||
/// <summary>
|
||||
/// GBK转UTF8
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
static std::string to_utf8(const std::string& value);
|
||||
static std::string to_gbk(const std::string& value);
|
||||
/// <summary>
|
||||
/// MD5校验
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
static std::string md5(const std::string& value);
|
||||
|
||||
static void regist(sol::state* lua);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,110 +0,0 @@
|
||||
/*Software License
|
||||
|
||||
Copyright(C) 2024[liuyingjie]
|
||||
License Terms
|
||||
Usage Rights
|
||||
|
||||
Any individual or entity is free to use, copy, and distribute the binary form of this software without modification to the source code, without the need to disclose the source code.
|
||||
If the source code is modified, the modifications must be open - sourced under the same license.This means that the modifications must be disclosed and accompanied by a copy of this license.
|
||||
Future Versions Updates
|
||||
From this version onwards, all future releases will be governed by the terms of the latest version of the license.This license will automatically be nullified and replaced by the new version.
|
||||
Users must comply with the terms of the new license issued in future releases.
|
||||
Liability and Disclaimer
|
||||
This software is provided “as is”, without any express or implied warranties, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non - infringement.In no event shall the author or copyright holder be liable for any claims, damages, or other liabilities, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software.
|
||||
Contact Information
|
||||
If you have any questions, please contact us: 1585346868@qq.com Or visit our website fwlua.com.
|
||||
*/
|
||||
#include "filesystem.h"
|
||||
#include "util/file.h"
|
||||
sol::table module::filesystem::list(const std::string& dirpath, const std::string& regex, sol::this_state s)
|
||||
{
|
||||
auto map = ylib::file::traverse(dirpath, regex);
|
||||
|
||||
sol::state_view lua(s);
|
||||
sol::table result_table = lua.create_table();
|
||||
int row_num = 1;
|
||||
|
||||
for_iter(iter, map)
|
||||
{
|
||||
sol::table row = lua.create_table();
|
||||
row["file"] = iter->first;
|
||||
row["type"] = (int)iter->second;
|
||||
result_table[row_num++] = row;
|
||||
}
|
||||
return result_table;
|
||||
}
|
||||
void module::filesystem::copy_dir(const std::string& src_dir, const std::string& dst_dir)
|
||||
{
|
||||
ylib::file::copy_dir(src_dir, dst_dir);
|
||||
}
|
||||
bool module::filesystem::create_dir(const std::string& dirpath)
|
||||
{
|
||||
return ylib::file::create_dir(dirpath, true);
|
||||
}
|
||||
sol::object module::filesystem::read(const std::string& filepath, sol::this_state s)
|
||||
{
|
||||
sol::object result;
|
||||
ylib::buffer data;
|
||||
if (ylib::file::read(filepath, data) == false)
|
||||
result = sol::make_object(s, data.to_string());
|
||||
else
|
||||
result = sol::make_object(s, sol::nil);
|
||||
return result;
|
||||
}
|
||||
bool module::filesystem::write(const std::string& filepath, const std::string& data)
|
||||
{
|
||||
return ylib::file::write(filepath, data);
|
||||
}
|
||||
bool module::filesystem::remove(const std::string& filepath)
|
||||
{
|
||||
return ylib::file::remove(filepath);
|
||||
}
|
||||
bool module::filesystem::remove_dir(const std::string& dirpath, bool recycle)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return ylib::file::remove_dir(dirpath, recycle);
|
||||
#else
|
||||
return ylib::file::remove_dir(dirpath);
|
||||
#endif
|
||||
}
|
||||
bool module::filesystem::exist(const std::string& filepath)
|
||||
{
|
||||
return ylib::file::exist(filepath);
|
||||
}
|
||||
bool module::filesystem::exist_dir(const std::string& dirpath)
|
||||
{
|
||||
return ylib::file::exist_dir(dirpath);
|
||||
}
|
||||
int64 module::filesystem::size(const std::string& filepath)
|
||||
{
|
||||
return ylib::file::size(filepath);
|
||||
}
|
||||
bool module::filesystem::copy(const std::string& src, const std::string& dst)
|
||||
{
|
||||
return ylib::file::copy(src, dst);
|
||||
}
|
||||
timestamp module::filesystem::last_write_time(const std::string& filepath)
|
||||
{
|
||||
return ylib::file::last_write_time(filepath);
|
||||
}
|
||||
void module::filesystem::regist(sol::state* lua)
|
||||
{
|
||||
(*lua)["IS_FILE"] = (int)ylib::FileType::IS_FILE;
|
||||
(*lua)["IS_DIRECTORY"] = (int)ylib::FileType::IS_DIRECTORY;
|
||||
|
||||
|
||||
lua->new_usertype<module::filesystem>("fs",
|
||||
"list", &module::filesystem::list,
|
||||
"copy_dir", &module::filesystem::copy_dir,
|
||||
"create_dir", &module::filesystem::create_dir,
|
||||
"read", module::filesystem::read,
|
||||
"write", module::filesystem::write,
|
||||
"remove", module::filesystem::remove,
|
||||
"remove_dir", module::filesystem::remove_dir,
|
||||
"exist", module::filesystem::exist,
|
||||
"exist_dir", module::filesystem::exist_dir,
|
||||
"size", module::filesystem::size,
|
||||
"copy", module::filesystem::copy,
|
||||
"last_write_time", module::filesystem::last_write_time
|
||||
);
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
#pragma once
|
||||
#include "sol/sol.hpp"
|
||||
#include "core/define.h"
|
||||
namespace module
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件
|
||||
/// </summary>
|
||||
class filesystem {
|
||||
public:
|
||||
static sol::table list(const std::string& dirpath,const std::string& regex,sol::this_state s);
|
||||
static void copy_dir(const std::string& src_dir,const std::string& dst_dir);
|
||||
static bool create_dir(const std::string& dirpath);
|
||||
static sol::object read(const std::string& filepath,sol::this_state s);
|
||||
static bool write(const std::string& filepath,const std::string& data);
|
||||
static bool remove(const std::string& filepath);
|
||||
static bool remove_dir(const std::string& dirpath, bool recycle);
|
||||
static bool exist(const std::string& filepath);
|
||||
static bool exist_dir(const std::string& dirpath);
|
||||
static int64 size(const std::string& filepath);
|
||||
static bool copy(const std::string& src, const std::string& dst);
|
||||
static timestamp last_write_time(const std::string& filepath);
|
||||
|
||||
static void regist(sol::state* lua);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
/*Software License
|
||||
|
||||
Copyright(C) 2024[liuyingjie]
|
||||
License Terms
|
||||
Usage Rights
|
||||
|
||||
Any individual or entity is free to use, copy, and distribute the binary form of this software without modification to the source code, without the need to disclose the source code.
|
||||
If the source code is modified, the modifications must be open - sourced under the same license.This means that the modifications must be disclosed and accompanied by a copy of this license.
|
||||
Future Versions Updates
|
||||
From this version onwards, all future releases will be governed by the terms of the latest version of the license.This license will automatically be nullified and replaced by the new version.
|
||||
Users must comply with the terms of the new license issued in future releases.
|
||||
Liability and Disclaimer
|
||||
This software is provided “as is”, without any express or implied warranties, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non - infringement.In no event shall the author or copyright holder be liable for any claims, damages, or other liabilities, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software.
|
||||
Contact Information
|
||||
If you have any questions, please contact us: 1585346868@qq.com Or visit our website fwlua.com.
|
||||
*/
|
||||
|
||||
#include "ini.h"
|
||||
|
||||
module::ini::ini()
|
||||
{
|
||||
}
|
||||
|
||||
module::ini::~ini()
|
||||
{
|
||||
}
|
||||
|
||||
bool module::ini::open(const std::string& filepath)
|
||||
{
|
||||
return m_ini.open(filepath);
|
||||
}
|
||||
|
||||
void module::ini::close()
|
||||
{
|
||||
m_ini.close();
|
||||
}
|
||||
|
||||
std::string module::ini::read(const std::string& node, const std::string& key, const std::string& default_value) const
|
||||
{
|
||||
return m_ini.read(node,key,default_value);
|
||||
}
|
||||
|
||||
bool module::ini::write(const std::string& node, const std::string& key, const std::string& value)
|
||||
{
|
||||
return m_ini.write(node,key,value);
|
||||
}
|
||||
|
||||
bool module::ini::del(const std::string& node, const std::string& key)
|
||||
{
|
||||
return m_ini.del(node, key);
|
||||
}
|
||||
|
||||
sol::table module::ini::nodes(sol::this_state s)
|
||||
{
|
||||
sol::state_view lua(s);
|
||||
sol::table result_table = lua.create_table();
|
||||
int row_num = 1;
|
||||
auto names = m_ini.names();
|
||||
for_iter(iter, names)
|
||||
result_table[row_num++] = *iter;
|
||||
return result_table;
|
||||
}
|
||||
|
||||
sol::table module::ini::keys(const std::string& node, sol::this_state s)
|
||||
{
|
||||
sol::state_view lua(s);
|
||||
sol::table result_table = lua.create_table();
|
||||
int row_num = 1;
|
||||
auto names = m_ini.keys(node);
|
||||
for_iter(iter, names)
|
||||
result_table[row_num++] = *iter;
|
||||
return result_table;
|
||||
}
|
||||
bool module::ini::exist_key(const std::string& node, const std::string& key)
|
||||
{
|
||||
return m_ini.exist_key(node, key);
|
||||
}
|
||||
|
||||
bool module::ini::exist_node(const std::string& node)
|
||||
{
|
||||
return m_ini.exist_name(node);
|
||||
}
|
||||
|
||||
sol::table module::ini::table(sol::this_state s)
|
||||
{
|
||||
sol::state_view lua(s);
|
||||
sol::table result_table = lua.create_table();
|
||||
|
||||
|
||||
auto nodes = m_ini.names();
|
||||
for_iter(iter, nodes)
|
||||
{
|
||||
sol::table node_table = lua.create_table();
|
||||
auto keys = m_ini.keys(*iter);
|
||||
for (size_t i = 0; i < keys.size(); i++)
|
||||
{
|
||||
node_table[keys[i]] = m_ini.read(*iter,keys[i]);
|
||||
}
|
||||
result_table[*iter] = node_table;
|
||||
}
|
||||
return result_table;
|
||||
}
|
||||
|
||||
void module::ini::regist(sol::state* lua)
|
||||
{
|
||||
lua->new_usertype<module::ini>("ini",
|
||||
"new", sol::constructors<module::ini()>(),
|
||||
"close", &module::ini::close,
|
||||
"del", &module::ini::del,
|
||||
"exist_key", &module::ini::exist_key,
|
||||
"exist_node", &module::ini::exist_node,
|
||||
"keys", &module::ini::keys,
|
||||
"nodes", &module::ini::nodes,
|
||||
"open", &module::ini::open,
|
||||
"read", &module::ini::read,
|
||||
"table", &module::ini::table,
|
||||
"write", &module::ini::write
|
||||
);
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
#pragma once
|
||||
#include "sol/sol.hpp"
|
||||
#include "util/ini.h"
|
||||
namespace module
|
||||
{
|
||||
/// <summary>
|
||||
/// INI配置
|
||||
/// </summary>
|
||||
class ini {
|
||||
public:
|
||||
ini();
|
||||
~ini();
|
||||
bool open(const std::string& filepath);
|
||||
void close();
|
||||
std::string read(const std::string& node, const std::string& key, const std::string& default_value) const;
|
||||
bool write(const std::string& node, const std::string& key, const std::string& value);
|
||||
bool del(const std::string& node, const std::string& key);
|
||||
sol::table nodes(sol::this_state s);
|
||||
sol::table keys(const std::string& node, sol::this_state s);
|
||||
bool exist_key(const std::string& node, const std::string& key);
|
||||
bool exist_node(const std::string& node);
|
||||
sol::table table(sol::this_state s);
|
||||
|
||||
static void regist(sol::state* lua);
|
||||
private:
|
||||
ylib::ini m_ini;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
/*Software License
|
||||
|
||||
Copyright(C) 2024[liuyingjie]
|
||||
License Terms
|
||||
Usage Rights
|
||||
|
||||
Any individual or entity is free to use, copy, and distribute the binary form of this software without modification to the source code, without the need to disclose the source code.
|
||||
If the source code is modified, the modifications must be open - sourced under the same license.This means that the modifications must be disclosed and accompanied by a copy of this license.
|
||||
Future Versions Updates
|
||||
From this version onwards, all future releases will be governed by the terms of the latest version of the license.This license will automatically be nullified and replaced by the new version.
|
||||
Users must comply with the terms of the new license issued in future releases.
|
||||
Liability and Disclaimer
|
||||
This software is provided “as is”, without any express or implied warranties, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non - infringement.In no event shall the author or copyright holder be liable for any claims, damages, or other liabilities, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software.
|
||||
Contact Information
|
||||
If you have any questions, please contact us: 1585346868@qq.com Or visit our website fwlua.com.
|
||||
*/
|
||||
|
||||
#include "sys.h"
|
||||
#include "util/system.h"
|
||||
std::string module::sys::current_dir()
|
||||
{
|
||||
return system::current_dir();
|
||||
}
|
||||
void module::sys::sleep_msec(uint32 msec)
|
||||
{
|
||||
system::sleep_msec(msec);
|
||||
}
|
||||
int64 module::sys::random(int64 min, int64 max)
|
||||
{
|
||||
return system::random(min, max);
|
||||
}
|
||||
std::string module::sys::current_filepath()
|
||||
{
|
||||
return system::current_filepath();
|
||||
}
|
||||
std::string module::sys::temp_path()
|
||||
{
|
||||
return system::temp_path();
|
||||
}
|
||||
std::string module::sys::desktop_path()
|
||||
{
|
||||
return system::desktop_path();
|
||||
}
|
||||
std::string module::sys::currentuser_path()
|
||||
{
|
||||
return system::currentuser_path();
|
||||
}
|
||||
sol::table module::sys::mac(sol::this_state s)
|
||||
{
|
||||
sol::state_view lua(s);
|
||||
sol::table result_table = lua.create_table();
|
||||
auto macs = system::mac();
|
||||
for(size_t i=0;i<macs.size();i++)
|
||||
result_table[i+1] = macs[i];
|
||||
return result_table;
|
||||
}
|
||||
void module::sys::regist(sol::state* lua)
|
||||
{
|
||||
lua->new_usertype<module::sys>("sys",
|
||||
"current_dir", &module::sys::current_dir,
|
||||
"sleep_msec", &module::sys::sleep_msec,
|
||||
"random", &module::sys::random,
|
||||
"current_filepath", &module::sys::current_filepath,
|
||||
"temp_path", &module::sys::temp_path,
|
||||
"desktop_path", &module::sys::desktop_path,
|
||||
"currentuser_path", &module::sys::currentuser_path,
|
||||
"mac", &module::sys::mac
|
||||
);
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
#pragma once
|
||||
#include "sol/sol.hpp"
|
||||
#include "core/define.h"
|
||||
namespace module
|
||||
{
|
||||
/// <summary>
|
||||
/// 系统
|
||||
/// </summary>
|
||||
class sys {
|
||||
public:
|
||||
static std::string current_dir();
|
||||
static void sleep_msec(uint32 msec);
|
||||
static int64 random(int64 min, int64 max);
|
||||
static std::string current_filepath();
|
||||
static std::string temp_path();
|
||||
static std::string desktop_path();
|
||||
static std::string currentuser_path();
|
||||
static sol::table mac(sol::this_state s);
|
||||
|
||||
static void regist(sol::state* lua);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
/*Software License
|
||||
|
||||
Copyright(C) 2024[liuyingjie]
|
||||
License Terms
|
||||
Usage Rights
|
||||
|
||||
Any individual or entity is free to use, copy, and distribute the binary form of this software without modification to the source code, without the need to disclose the source code.
|
||||
If the source code is modified, the modifications must be open - sourced under the same license.This means that the modifications must be disclosed and accompanied by a copy of this license.
|
||||
Future Versions Updates
|
||||
From this version onwards, all future releases will be governed by the terms of the latest version of the license.This license will automatically be nullified and replaced by the new version.
|
||||
Users must comply with the terms of the new license issued in future releases.
|
||||
Liability and Disclaimer
|
||||
This software is provided “as is”, without any express or implied warranties, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non - infringement.In no event shall the author or copyright holder be liable for any claims, damages, or other liabilities, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software.
|
||||
Contact Information
|
||||
If you have any questions, please contact us: 1585346868@qq.com Or visit our website fwlua.com.
|
||||
*/
|
||||
|
||||
#include "time.h"
|
||||
#include "util/time.h"
|
||||
uint64 module::time::now_msec()
|
||||
{
|
||||
return ylib::time::now_msec();
|
||||
}
|
||||
uint64 module::time::now_sec()
|
||||
{
|
||||
return ylib::time::now_sec();
|
||||
}
|
||||
|
||||
std::string module::time::now_time(const std::string& format)
|
||||
{
|
||||
return ylib::time::now_time(format);
|
||||
}
|
||||
|
||||
void module::time::regist(sol::state* lua)
|
||||
{
|
||||
lua->new_usertype<module::time>("time",
|
||||
"now_msec", &module::time::now_msec,
|
||||
"now_sec", &module::time::now_sec,
|
||||
"now_time", &module::time::now_time
|
||||
);
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
#pragma once
|
||||
#include "sol/sol.hpp"
|
||||
#include "core/define.h"
|
||||
namespace module
|
||||
{
|
||||
/// <summary>
|
||||
/// 时间
|
||||
/// </summary>
|
||||
class time {
|
||||
public:
|
||||
static uint64 now_msec();
|
||||
static uint64 now_sec();
|
||||
static std::string now_time(const std::string& format);
|
||||
static void regist(sol::state* lua);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user