可以突破木屋所有云的限制,原理是将云存储至自己的电脑磁盘,默认存储在D:\openxmw\cloud下,可在C++程序内更改
该程序由python调用C++实现,主要原因:
1.C++的运行效率是python的10倍以上,适合大数据处理
2.C++有着优秀的STL库
3.python负责参数处理,C++负责执行
4.我不怎么会python
该插件还有很多功能尚未实现(未来预计会加入排序、去重、处理列表存储等功能),目前仅支持:(部分未测试)
当userID为空时将存储自公共空间,否则存储至私有空间
name为存储项名称
text为内容
opencloud.save
参数:userID,text,name 将存储入指定名称,替换原有内容
opencloud.add
参数:userID,text,name 将追加于指定名称,保存原有内容
opencloud.get
参数:userID,name 将获取于指定名称
opencloud.delete
参数:userID,name 将删除指定名称,名称为空时则删除该用户所有
opencloud.clear
无参数 清除所有存储内容
由于我这不能上传文件,所以就贴代码上来了:
opencloud.py:
def save(params):
import os
if not params['userID']:
uid='public'
else:
uid=params['userID']
if not params['name']:
name='default'
else:
name=params['name']
os.system("c++\\opencloud.exe save "+uid+" \""+name+"\" \""+params['text']+"\" >c++\\tmp.txt")
file_object=open("c++\\tmp.txt",'r')
rt=file_object.readline()
file_object.close()
return {'return':rt}
def add(params):
import os
if not params['userID']:
uid='public'
else:
uid=params['userID']
if not params['name']:
name='default'
else:
name=params['name']
os.system("c++\\opencloud.exe add "+uid+" \""+name+"\" \""+params['text']+"\" >c++\\tmp.txt")
file_object=open("c++\\tmp.txt",'r')
rt=file_object.readline()
file_object.close()
return {'return':rt}
def get(params):
import os
if not params['userID']:
uid='public'
else:
uid=params['userID']
if not params['name']:
name='default'
else:
name=params['name']
os.system("c++\\opencloud.exe get "+uid+" \""+name+"\" >c++\\tmp.txt")
file_object=open("c++\\tmp.txt",'r')
rt=file_object.readline()
file_object.close()
return {'return':rt}
def delete(params):
import os
if not params['userID']:
uid='public'
else:
uid=params['userID']
if not params['name']:
os.system("c++\\opencloud.exe delete "+uid+" \""+name+"\" >c++\\tmp.txt")
else:
os.system("c++\\opencloud.exe delete "+uid+" >c++\\tmp.txt")
file_object=open("c++\\tmp.txt",'r')
rt=file_object.readline()
file_object.close()
return {'return':rt}
def clear(params):
import os
os.system("c++\\opencloud.exe clear >c++\\tmp.txt")
file_object=open("c++\\tmp.txt",'r')
rt=file_object.readline()
file_object.close()
return {'return':rt}
opencloud.cpp(需要自己编译成exe):
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
//ll max(ll x,ll y){return x>y?x:y;}
FILE *a,*tmpout=stdout;
string npath="D:\\openxmw\\cloud";
string path,nm,mode;
signed main(int argc,char* argv[]){
//mode uid name text
mode=argv[1];
if(mode=="save"||mode=="add"){
path=npath+"\\"+argv[2];
system(("if not exist "+path+" mkdir "+path).c_str());
path=path+"\\"+argv[3];
a=fopen(path.c_str(),mode=="save"?"w":"a+");
printf("%d",fprintf(a,"%s",argv[4]));
fclose(a);
}
if(mode=="delete"){
path=npath+"\\"+argv[2];
if(argc>3) path=path+"\\"+argv[3],printf("%d",remove(path.c_str())+1);
else printf("%d",system(("mrdir /s /q "+path).c_str()));
}
if(mode=="clear") printf("%d",system(("mrdir /s /q "+npath).c_str()));
if(mode=="exist"){
if(argc<=3) printf("0"),exit(0);
path=npath+"\\"+argv[2]+"\\"+argv[3];
if(a=fopen(path.c_str(),"r")) printf("1"),fclose(a);
else printf("0");
}
if(mode=="get"){
path=npath+"\\"+argv[2]+"\\"+argv[3];
freopen(path.c_str(),"r",stdout);
string s;
getline(cin,s);
fprintf(tmpout,s.c_str());
fclose(a);
}
return 0;
}
(我的代码风格可能有点奇怪不用管)
使用说明:
将C++文件编译成exe后命名为"opencloud.exe"后放于core.pyc同目录的c++文件夹下(需要自己建)