0 Star 2 Fork 1

Cadaqs/XStudio

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
XPlatform.xcsm 2.66 KB
一键复制 编辑 原始数据 按行查看 历史
Cadaqs 提交于 2020-11-28 21:28 . 9233
//xlang Source, Name:XPlatform.xcsm
//Date: Thu Jan 18:45:18 2019
class XPlatform{
static String [] os_names = {"Windows", "Linux", "MaxOSX", "Unknow"};
static String [] arch_names = {"Unknow", "x86", "x86_64", "arm", "arm64", "mips", "mips64"};
public static String getOSName(){
return os_names[_system_.getPlatformId()];
}
public static String getArchName(){
return arch_names[_system_.getArchId()];
}
public @NotNilptr static String converPlatformCharSetTo(@NotNilptr String filepath){
String original_path = filepath;
if (_system_.getPlatformId() == 0){
// windows 下要转成CP936
try{
original_path = new String(filepath.getBytes(), "CP936");
}catch(Exception e){
original_path = filepath;
}
}
return original_path;
}
public @NotNilptr static String converToPlatformCharSet(@NotNilptr String filepath){
String original_path = filepath;
if (_system_.getPlatformId() == 0){
// windows 下要转成CP936
try{
original_path = new String(filepath.getBytes("CP936"));
}catch(Exception e){
original_path = filepath;
}
}
return original_path;
}
public @NotNilptr static String getAppDirectory(){
return converPlatformCharSetTo(_system_.getAppDirectory());
}
public static long SystemFileSize(@NotNilptr String filepath){
String original_path = converToPlatformCharSet(filepath);
return _system_.getFileSize(original_path);
}
public static bool chmodSystemFile(@NotNilptr String filepath, int mode){
String original_path = converToPlatformCharSet(filepath);
return _system_.chmod(original_path, mode);
}
public static long openSystemFile(@NotNilptr String filepath,@NotNilptr String mode){
String original_path = converToPlatformCharSet(filepath);
return _system_.openFile(original_path, mode);
}
public static bool renameFile(@NotNilptr String oldfile,@NotNilptr String newfile){
String old_file = converToPlatformCharSet(oldfile);
String new_file = converToPlatformCharSet(newfile);
return _system_.rename(old_file, new_file);
}
public static bool existsSystemFile(@NotNilptr String filepath){
String original_path = converToPlatformCharSet(filepath);
return _system_.fileExists(original_path);
}
public static bool mkdir(@NotNilptr String filepath){
String original_path = converToPlatformCharSet(filepath);
return _system_.mkdir(original_path);
}
public static bool deleteFile(@NotNilptr String filepath){
String original_path = converToPlatformCharSet(filepath);
return _system_.deleteFile(original_path);
}
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/ixlang/XStudio.git
[email protected]:ixlang/XStudio.git
ixlang
XStudio
XStudio
master

搜索帮助