Commit cbb728ad authored by wanli's avatar wanli

update

parent 735d39eb
'''
Author: your name
Date: 2021-04-14 14:12:18
LastEditTime: 2021-06-22 12:40:53
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath: \evm-store\backend\app\signal_manager.py
'''
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf_8 -*- # -*- coding: utf_8 -*-
...@@ -9,6 +17,7 @@ class SignalManager(object): ...@@ -9,6 +17,7 @@ class SignalManager(object):
actionBackupDatabase = PySignal() actionBackupDatabase = PySignal()
actionApplicationBuild = PySignal() actionApplicationBuild = PySignal()
actionGetConvertString = PySignal() actionGetConvertString = PySignal()
actionOpqcp = PySignal()
# 登录模块 # 登录模块
actionLogin = PySignal() actionLogin = PySignal()
......
'''
Author: your name
Date: 2021-04-14 14:12:18
LastEditTime: 2021-06-22 12:41:13
LastEditors: your name
Description: In User Settings Edit
FilePath: \evm-store\backend\controller\__init__.py
'''
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf_8 -*- # -*- coding: utf_8 -*-
import os import os
...@@ -24,6 +32,7 @@ def initConnect(): ...@@ -24,6 +32,7 @@ def initConnect():
signalManager.actionApplicationBuild.connect(appsManager.build) signalManager.actionApplicationBuild.connect(appsManager.build)
signalManager.actionGetConvertString.connect(apiManager.get_escape_text) signalManager.actionGetConvertString.connect(apiManager.get_escape_text)
signalManager.actionUpdatePassword.connect(apiManager.update_user_password) signalManager.actionUpdatePassword.connect(apiManager.update_user_password)
signalManager.actionOpqcp.connect(apiManager.opqcp)
# 登录模块 # 登录模块
signalManager.actionLogin.connect(loginManager.login) signalManager.actionLogin.connect(loginManager.login)
......
'''
Author: your name
Date: 2021-04-14 14:12:18
LastEditTime: 2021-06-22 13:38:34
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath: \evm-store\backend\controller\api_manager.py
'''
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf_8 -*- # -*- coding: utf_8 -*-
import os
import time import time
import json import json
import logging import logging
import traceback import traceback
import subprocess
import uuid import uuid
from datetime import datetime from datetime import datetime
from pony.orm import * from pony.orm import *
from model import fullStackDB from app.setting import config
from model.user import User from model.user import User
from utils import md5_salt from utils import md5_salt
from utils.ccode import convert_string from utils.ccode import convert_string
...@@ -49,4 +59,28 @@ class ApiManager(object): ...@@ -49,4 +59,28 @@ class ApiManager(object):
def get_escape_text(self, data): def get_escape_text(self, data):
return convert_string(data['string']) return convert_string(data['string'])
def opqcp(self, params):
target_file = os.path.normpath(os.sep.join([config.get("UPLOAD_PATH"), params.get("filename")]))
print("--------->", params, target_file)
print(os.stat(target_file))
# dtNowString = datetime.now().strftime("%Y%m%d%H%M%S%f")
# fn, ex = os.path.splitext(params.get("filename"))
output_path = os.path.dirname(target_file)
print("#######", output_path)
# command = ["./opqcp", target_file, output_path]
# ret = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8", timeout=5)
# if ret.returncode == 0:
# print("success:", ret)
# else:
# print("error:", ret)
ret = target_file
return True, ret
apiManager = ApiManager() apiManager = ApiManager()
...@@ -29,11 +29,15 @@ def stopApp(): ...@@ -29,11 +29,15 @@ def stopApp():
f.write(json.dumps(ret, indent=4)) f.write(json.dumps(ret, indent=4))
return ret return ret
def actionShowReport(): @api.route("/opqcp", methods=['POST'])
fpath = os.sep.join([os.getcwd(), "results", "TPC-E_dm.pdf"]) def action_opqcp():
with open(fpath, "rb") as f: params = request.json
ret = f.read()
return ret print(params)
signalManager.actionOpqcp.emit(params)
return response_result(ResponseCode.OK)
@api.route("/updatePassword", methods=['POST']) @api.route("/updatePassword", methods=['POST'])
@validate_schema(UpdatePasswordSchema) @validate_schema(UpdatePasswordSchema)
...@@ -49,11 +53,10 @@ def update_password(): ...@@ -49,11 +53,10 @@ def update_password():
def upload_file(): def upload_file():
try: try:
result = None result = None
message = None
binfile = request.files.get("binfile") binfile = request.files.get("binfile")
if not binfile: if not binfile:
return response_result(ResponseCode.REQUEST_ERROR, msg=message) return response_result(ResponseCode.REQUEST_ERROR, msg="upload field name error")
obj = dict() obj = dict()
obj['filename'] = binfile.filename obj['filename'] = binfile.filename
...@@ -83,10 +86,10 @@ def upload_file(): ...@@ -83,10 +86,10 @@ def upload_file():
"uuid": str(uuid.uuid4()), # 附件唯一编号 "uuid": str(uuid.uuid4()), # 附件唯一编号
"filename": obj['filename'], # 附件名称 "filename": obj['filename'], # 附件名称
"filesize": os.path.getsize(saveFile), # 附件大小 "filesize": os.path.getsize(saveFile), # 附件大小
"filepath": os.sep.join([config.get("UPLOAD_DIR"), relative_path, filename]).replace("\\", "/"), # 附件存储路径 "filepath": os.sep.join([relative_path, filename]).replace("\\", "/"), # 附件存储路径
}, "upload file [%s] successfully!" % obj['filename'] }
return response_result(ResponseCode.OK, data=result) return response_result(ResponseCode.OK, data=result, msg="upload file [%s] successfully!" % obj['filename'])
except Exception as e: except Exception as e:
traceback.print_exc() traceback.print_exc()
logger.error(str(e)) logger.error(str(e))
......
...@@ -239,6 +239,14 @@ export function getConvertString(params) { ...@@ -239,6 +239,14 @@ export function getConvertString(params) {
}); });
} }
export function actionOpqcp(params) {
return request({
url: "/api/v1/evm_store/opqcp",
method: "post",
data: params,
});
}
export function getTopicList(params) { export function getTopicList(params) {
return request({ return request({
url: "/uowap/index", url: "/uowap/index",
......
...@@ -208,6 +208,17 @@ export const constantRoutes = [ ...@@ -208,6 +208,17 @@ export const constantRoutes = [
meta: { title: '下载记录', icon: 'gongzuotai' } meta: { title: '下载记录', icon: 'gongzuotai' }
}] }]
}, },
{
path: '/',
redirect: '/opqcp',
component: Layout,
children: [{
path: 'opqcp',
name: 'Opqcp',
component: () => import('@/views/system/opqcp'),
meta: { title: 'opqcp', icon: 'home' }
}]
},
{ {
path: '/', path: '/',
redirect: '/device', redirect: '/device',
......
<template>
<div class="app-container">
<el-alert title="代码混淆工具" type="success"></el-alert>
<div style="margin: 10px 0px">
<el-form>
<el-form-item>
<el-upload
class="upload-demo"
action="/api/v1/evm_store/upload"
name="binfile"
:on-success="handleUploaded"
:file-list="fileList"
>
<el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">
上传C源文件,转换完成后会自动下载
</div>
</el-upload>
</el-form-item>
<el-form-item>
<el-button type="success" @click="getConvertString">转换</el-button>
</el-form-item>
</el-form>
</div>
</div>
</template>
<script>
import { actionOpqcp } from "@/api/app-store";
export default {
name: "Opqcp",
data() {
return {
fileList: [],
inputString: null,
outputString: null,
filename: "app.js",
};
},
methods: {
createFile(content, filename) {
const a = document.createElement("a");
const blob = new Blob([content]);
const url = window.URL.createObjectURL(blob);
a.href = url;
a.download = filename;
a.click();
window.URL.revokeObjectURL(url);
},
handleUploaded(response) {
if (response.code == 200) {
this.filename = response.data.filename
actionOpqcp({ filename: response.data.filepath })
.then((res) => {
this.$message.success(res.message);
// const a = document.createElement("a");
// a.href = url;
// a.download = filename;
// a.click();
})
.catch((err) => {
this.$message.error(err.message);
});
}
console.log(response)
},
downloadFile() {
this.$prompt("请输入文件名", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
inputValue: this.filename,
inputErrorMessage: "文件名格式不正确",
})
.then(({ value }) => {
if (value) this.filename = value;
this.createFile(this.outputString, this.filename);
})
.catch(() => {
this.$message({
type: "info",
message: "取消输入",
});
});
},
getConvertString() {
},
},
mounted() {},
created() {},
};
</script>
<style lang="scss" scoped>
.app-container {
& > div.page-wrapper {
margin: 10px 0px;
}
}
</style>
/*
* list.h - Definitions for list datastructures.
*
* Author: Russ Fish
* Computer Science Dept.
* University of Utah
* Date: 1 August 1980
*/
#ifndef LISTLINKS /* only once */
/*****************************************************************/
/* TAG( list LISTHDR TLISTHDR NULLPTR P N T_P T_N ) */
/* TAG( LISTLINKS TLISTLINKS ) */
typedef /* Generalized list header. */
struct listhdr
{
int t_tag; /* object type tag */
struct listhdr *next,*prev; /* Backward & forward pointers */
}
list;
/* LISTLINKS = a type tag, followed by a LISTHDR */
#define LISTLINKS int t_tag; struct tlist * next, * prev
#define TLISTLINKS(type) int t_tag; type * next, * prev
/* Access for List pointer manipulations. (Previous and Next.) */
#define P(node) ((node)->prev)
#define N(node) ((node)->next)
/* #define P(node) (((list *)(node))->prev)
* #define N(node) (((list *)(node))->next)
*/
/* Versions of P and N with cast on result to set list subtype properly. */
#define T_P(type,node) ((type *)(node)->prev)
#define T_N(type,node) ((type *)(node)->next)
/* *****************************************************************
* TAG( list_list LLIST NEW_LIST_LIST )
*
* list of lists data structure.
*/
typedef struct list_list
{
TLISTLINKS(struct list_list);
list * l_list;
} list_list;
#define LLIST(type,ll) (type *)ll->l_list /* get the list pointed to */
/*****************************************************************/
/* TAG( ADD INSERT REMOVE ) */
/* ADD links new members into a list, given a pointer to the new member, and
* a pointer to the first (left) element of the list.
*/
#define ADD(new,first) ( P(new) = NULL ,N(new) = (first),\
( ((first)!=NULL) ? (P(first)=(new), 0) :0 ),\
first = (new) )
/* INSERT links members into the middle of a list, given a pointer to the new
* member, and a pointer to the list element to insert after.
*/
#define INSERT(new,after) ( P(new) = (after),N(new) = N(after),\
( (N(after)!=NULL) ? (P(N(after))=(new), 0) :0),\
N(after) = (new) )
/* REMOVE unlinks a list element from a list, given a pointer to the element.
*/
#define REMOVE(elt) ( ( (P(elt)!=NULL) ? (N(P(elt))=N(elt), 0) :0 ),\
( (N(elt)!=NULL) ? (P(N(elt))=P(elt), 0) :0) )
/****************************************************************
* TAG( TRACE FREE_LIST FIRSTP ENDP )
*
* TRACE - Traces a linear list.
* FREE_LIST - Walks a list, freeing the elements.
* FIRSTP - Tests an element, TRUE if it is the first.
* ENDP - Tests an element, TRUE if it is the end.
*/
#define TRACE(t_var,ini) for((t_var)=(ini);(t_var)!=NULL;(t_var)=N(t_var))
#define FREE_LIST(lst) {while(N(lst)){lst=N(lst);free(P(lst));} free(lst);}
#define FIRSTP(ptr) (P(ptr) == NULL)
#define ENDP(ptr) (N(ptr) == NULL)
/****************************************************************
* TAGS( DEL )
* del deletes an element from a list, updating the base
* pointer of the list if necesary.
*/
#define DEL(elt,base) ( ( (P(elt)!=NULL) ? (N(P(elt)) = N(elt)) :0 ),\
( (N(elt)!=NULL) ? (P(N(elt)) = P(elt)) :0) ,\
( ((elt)==(base)) ? ((base)= N(base) ) :0) )
#endif LISTLINKS
# Makefile for opqcp.
CFLAGS = -g
OFILES = opqcp.o symtab.o new.o
opqcp: $(OFILES)
gcc -o opqcp $(CFLAGS) $(OFILES)
opqcp.o: misc.h symtab.h
symtab.o: misc.h symtab.h
new.o: misc.h
/*
* misc.h - Just the subset of defs needed for opqcp.
*
* Author: Russ Fish
* Computer Science Dept.
* University of Utah
* Date: 1 August 1980
*/
#ifndef MISCH /* Only once. */
#define MISCH
#include <stdio.h> /* Defines NULL. */
/*****************************************************************
* TAGS( string boolean fn byte address )
*
* Commonly used types.
*
*/
typedef char * string; /* Character Strings. */
typedef int boolean; /* Logical vars or values. */
typedef char byte; /* Byte is the unit of "sizeof". */
typedef char * address;
/*****************************************************************
* TAGS( TRUE FALSE )
*/
#define TRUE 1 /* Logical constants. */
#define FALSE 0
/*****************************************************************
* TAGS( NEW NEW_1 NEW_N new )
*
* NEW(type,size)
* Generalized allocation function, given an object type and size (in
* bytes) to be allocated.
*
* Variants:
* NEW_1(type) - Allocate a single object of the given type.
* NEW_N(type,n) - Allocate an array of N objects of the given type.
*/
extern address
new(); /* In-core allocator. */
/* ( size )
* int size;
*/
#define NEW(type,size) (type *)new(size) /* Macro with type cast. */
#define NEW_1(type) (type *)new(sizeof(type)) /* Single arg, fixed size. */
#define NEW_N(type,n) (type *)new((n)*sizeof(type)) /* Array of base type. */
/*****************************************************************
* TAGS( FREE free dispose )
*
* Macros to cast the argument to dispose().
*/
#define FREE( ptr ) dispose( (address)ptr )
#define free( ptr ) dispose( (address)ptr )
/*****************************************************************
* TAG( SIZE SIZE_N msize )
*
* SIZE returns the size (in bytes) of an allocated object.
*
* SIZE_N returns the number of objects of TYPE in ARRAY.
*/
extern long
msize();
/* ( obj )
* address obj;
*/
#define SIZE(obj) msize( (address)obj )
#define SIZE_N(type, array) (msize( (address)array ) / sizeof (type))
#endif
/*
* new.c - Generalized allocation function.
*
* Author: Russ Fish
* Computer Science Dept.
* University of Utah
* Date: 1 August 1980
*/
#include "misc.h"
typedef union
{
long mem_size; /* Someplace to stash the actual block size. */
/* Avoid messing up the double alignment of the block we are wrapping. */
double dummy;
} mem_hdr;
extern char * malloc(); /* Use the Std I/O Mem Alloc. */
/*****************************************************************
* TAG( new )
*
* Allocate a block of storage.
*
*/
address
new(size)
int size;
{
mem_hdr * retval;
if ( (retval = (mem_hdr *)
malloc( (unsigned) (size + sizeof(mem_hdr)) )) <= 0 )
{
fprintf( stderr, "\nNo Space in heap! %d bytes requested.\n", size);
exit( -1 );
}
/* Fill in the specified block size in a header word. The returned
* pointer points just AFTER the mem_hdr. Only "new", "dispose",
* "msize", and "expand" need to know about the mem_hdr.
*/
retval->mem_size = (long) size;
return (address)( retval + 1 );
}
/*****************************************************************
* TAG( msize )
*
* Report the size of a block of storage.
*/
long
msize( obj )
address obj;
{
return ( (mem_hdr *)obj - 1 )->mem_size;
}
/*****************************************************************
* TAG( dispose )
*
* Free a block of storage.
*/
dispose( obj )
address obj;
{
/* Get the "free" compatibility macro out of the way. This is the
* only place in the system where the real "free" function is visible.
*/
# undef free
if ( obj )
free( (char *) ((mem_hdr *)obj - 1) );
}
File added
This diff is collapsed.
/* Licensed material, Copyright (c) 1985, University of Utah. */
extern struct l1{int l2;char*l3;char*l4;int l5;short l6;char l7;}l8[];struct
l1*l9();struct l1*l10();struct l1*l11();struct l1*l12();long l13();char*l14()
;char*l15();char*l16();typedef char*l17;typedef int l18;typedef char l19;
typedef char*l20;extern l20 l21();extern long l22();typedef struct l23{int l24
;struct l23*l25,*l26;}l27;typedef struct l28{int l24;struct l28*l25,*l26;l27*
l29;}l28;typedef struct l30 l31;struct l30{int l24;l31*l25,*l26;l17 l32;l20
l33;};extern l31*l34();extern l31*l35();typedef struct{int l36;l31*l37[1];}
l38;extern l38*l39();extern l31**l40();extern l41();extern l42();typedef
unsigned char l43;typedef unsigned short l44;typedef unsigned int l45;typedef
unsigned long l46;typedef unsigned short l47;typedef struct l48{short l49[1];
}*l50;typedef struct l51{int l52[15];}l51;typedef struct l53{long l52[2];}l54
;typedef long l55;typedef char*l56;typedef long*l57;typedef l46 l58;typedef
long l59;typedef long l60;typedef long l61;typedef short l62;typedef long l63
;typedef l44 l64;typedef l44 l65;typedef l46 l66;typedef long l67;typedef
struct l68{l67 l69[(((256)+(((sizeof(l67)*8))-1))/((sizeof(l67)*8)))];}l68;
struct l70{l62 l71;l58 l72;unsigned short l73;short l74;l64 l75;l65 l76;l62
l77;l63 l78;l61 l79;int l80;l61 l81;int l82;l61 l83;int l84;long l85;long l86
;long l87[2];};extern char l88[];l17 l89[] = {"int","char","float","double",
"struct","union","enum","long","short","unsigned","auto","extern","register",
"typedef","static","goto","return","sizeof","break","continue","if","else",
"for","do","while","switch","case","default","entry","fortran","asm","main",
"void"};int l90 = sizeof l89/sizeof(l17);main(l91,l92)int l91;l17 l92[];{l18
l93 = 0,l94 = 0;int l95,l96,l97,l98,l99;l38*l100,*l101;l31*l102;l17*l103,*
l104,l105;static char l106[1024] = {'\0'};char l107[1024],l108[1024];struct
l70 l109;struct l1*l110,*l111,*l112,*l12();l62 l113;l58 l114;l17 l115,l116,
l117,l118();char l119,*l120,l121[1024],*l122,l123;int l124,l125;enum{l126,
l127,l128,l129,l130}l131,l132;static l17 l133[] = {"none","symbol","string",
"number","other"};l18 l134;l17 l135 = "=!<>&|+-*/%&^";int l136 = 0;static char
l137[5000][6];for(l95=0;l95<5000/1000;l95++)for(l96=0;l96<=9;l96++)for(l97=0;
l97<=9;l97++)for(l98=0;l98<=9;l98++){l120 = l137[l136++];*l120++ = 'l';if(l95
)*l120++ = '0'+l95;if(l95||l96)*l120++ = '0'+l96;if(l95||l96||l97)*l120++ =
'0'+l97;*l120++ = '0'+l98;*l120 = '\0';}l100 = l39(1000);for(l95=0,l103 = l89
;l95<l90;l95++,l103++)l34(*l103,l100);for(l99=1,l104 = &l92[1],l105 = *l104;
l99<l91;l99++,l104++,l105 = *l104){if(l105[0]!= '-')break;if(l138(l105,"-d")
== 0){if(++l99>= l91-1)break;l105 = *++l104;if((l110 = l9(l105,"r")) == 0){
l16(l107,"opqcp: Can't open dictionary %s\n",l105);l139(l107);l140(1);}while(
l14(l107,1024,l110)!= 0){l107[l141(l107)-1] = '\0';if((l117 = l118(l107,' '))
!= 0)*l117++ = '\0';l116 = (char*)l21(l141(l107)+1);l142(l116,l107);l102 =
l34(l116,l100);if(l117!= 0){l102->l33 = (char*)l21(l141(l117)+1);l142(l102->
l33,l117);}}l143(l110);}else if(l144(l105,"-I",2) == 0){l145(l106," ");l145(
l106,l105);}else if(l138(l105,"-t") == 0){l94 = 1;goto l146;}else if(l138(
l105,"-f") == 0){l146:l93 = 1;l111 = (&l8[0]);l112 = (&l8[1]);}else break;}if
(l105[0] == '-'||!l93&&l91-l99<2){l147((&l8[2]),"%s\n%s\n",
"usage: opqcp [-d dict]* [-Idir]* [srcfile]+ destdir",
" or opqcp [-d dict]* -f");l140(2);}if(!l93){if(l70(l115 = l92[l91-1],&
l109) == -1){l16(l107,"opqcp: Can't stat directory %s\n",l115);l139(l107);
l140(1);}if(!(l109.l73&0040000)){l147((&l8[2]),
"opqcp: %s is not a directory.\n",l115);l140(1);}}for(;l93||l99<l91-1;l99++,
l104++){if(l93)l105 = "(stdin)";else{l105 = *l104;if(l70(l105,&l109) == -1){
l16(l107,"opqcp: Can't stat input file %s\n",l105);l139(l107);continue;}if(!(
l109.l73&0100000)){l147((&l8[2]),"opqcp: %s is not a plain file.\n",l105);
continue;}l113 = l109.l71;l114 = l109.l72;l16(l107,"%s/%s",l115,l105);if(l70(
l107,&l109) == 0){if(l109.l71 == l113&&l109.l72 == l114){l147((&l8[2]),
"opqcp: Can't copy file %s to itself.\n",l105);continue;}if(!(l109.l73&
0100000)){l147((&l8[2]),"opqcp: %s is not a plain file.\n",l107);continue;}}
if((l112 = l9(l107,"w")) == 0){l16(l107,"opqcp: Can't write file %s",l105);
l139(l107);continue;}l148("/* Licensed material, Copyright ",l112);l148(
"(c) 1985, University of Utah. */\n",l112);l16(l108,"cc -E %s %s",l106,l105);
if((l111 = l12(l108,"r")) == 0){l16(l108,"opqcp: Couldn't start cpp on %s.",
l105);l139(l108);l143(l112);l149(l107);continue;}}l101 = l39(1000);l136 = 0;
l119 = '\n';(l125 = 0);l132 = l126;while(l119!= (-1)){(l122 = l121,*l122 =
'\0');l131 = l126;l134 = 0;while(((l88+1)[l119]&010)){l134 = 1;if(l119!= '\n'
)(l119 = (--(l111)->l2>=0?(int)(*(unsigned char*)(l111)->l3++):l150(l111)));
else{(l119 = (--(l111)->l2>=0?(int)(*(unsigned char*)(l111)->l3++):l150(l111)
));if(l119 == '#'){while(l119!= '\n'&&l119!= (-1))(l119 = (--(l111)->l2>=0?(
int)(*(unsigned char*)(l111)->l3++):l150(l111)));}}}if(((l88+1)[l119]&(01|02)
)||l119 == '_'){l131 = l127;((*l122++ = l119,*l122 = '\0'),(l119 = (--(l111)
->l2>=0?(int)(*(unsigned char*)(l111)->l3++):l150(l111))));while(((l88+1)[
l119]&(01|02|04))||l119 == '_')((*l122++ = l119,*l122 = '\0'),(l119 = (--(
l111)->l2>=0?(int)(*(unsigned char*)(l111)->l3++):l150(l111))));if((l102 =
l35(l121,l100))!= 0){if(l102->l33!= 0){l142(l121,l102->l33);}}else{if((l102 =
l35(l121,l101)) == 0){l116 = (char*)l21(l141(l121)+1);l142(l116,l121);l102 =
l34(l116,l101);l102->l33 = l137[++l136];}l142(l121,l102->l33);}}else if(l119
== '"'||l119 == '\''){l131 = l128;l123 = l119;((*l122++ = l119,*l122 = '\0'),
(l119 = (--(l111)->l2>=0?(int)(*(unsigned char*)(l111)->l3++):l150(l111))));
while(l119!= l123){if(l119!= '\\')((*l122++ = l119,*l122 = '\0'),(l119 = (--(
l111)->l2>=0?(int)(*(unsigned char*)(l111)->l3++):l150(l111))));else{((*l122
++ = l119,*l122 = '\0'),(l119 = (--(l111)->l2>=0?(int)(*(unsigned char*)(l111
)->l3++):l150(l111))));if(l123!= '"'||l119!= '\n')((*l122++ = l119,*l122 =
'\0'),(l119 = (--(l111)->l2>=0?(int)(*(unsigned char*)(l111)->l3++):l150(l111
))));else{((*l122++ = l119,*l122 = '\0'),(l119 = (--(l111)->l2>=0?(int)(*(
unsigned char*)(l111)->l3++):l150(l111))));if(l141(l121)+l125>77)l148("\n",
l112);l148(l121,l112);(l125 = 0);(l122 = l121,*l122 = '\0');}}}((*l122++ =
l119,*l122 = '\0'),(l119 = (--(l111)->l2>=0?(int)(*(unsigned char*)(l111)->l3
++):l150(l111))));}else if(((l88+1)[l119]&04)){l151:l131 = l129;if(l119 ==
'0'){((*l122++ = l119,*l122 = '\0'),(l119 = (--(l111)->l2>=0?(int)(*(unsigned
char*)(l111)->l3++):l150(l111))));if(l119 == 'x'||l119 == 'X'){((*l122++ =
l119,*l122 = '\0'),(l119 = (--(l111)->l2>=0?(int)(*(unsigned char*)(l111)->l3
++):l150(l111))));while(((l88+1)[l119]&04)||l119>= 'a'&&l119<= 'f'||l119>=
'A'&&l119<= 'F')((*l122++ = l119,*l122 = '\0'),(l119 = (--(l111)->l2>=0?(int)
(*(unsigned char*)(l111)->l3++):l150(l111))));}else while(((l88+1)[l119]&04))
((*l122++ = l119,*l122 = '\0'),(l119 = (--(l111)->l2>=0?(int)(*(unsigned char
*)(l111)->l3++):l150(l111))));}else while(((l88+1)[l119]&04))((*l122++ = l119
,*l122 = '\0'),(l119 = (--(l111)->l2>=0?(int)(*(unsigned char*)(l111)->l3++):
l150(l111))));if(l119 == 'l'||l119 == 'L')((*l122++ = l119,*l122 = '\0'),(
l119 = (--(l111)->l2>=0?(int)(*(unsigned char*)(l111)->l3++):l150(l111))));
else{if(l119 == '.'){((*l122++ = l119,*l122 = '\0'),(l119 = (--(l111)->l2>=0?
(int)(*(unsigned char*)(l111)->l3++):l150(l111))));while(((l88+1)[l119]&04))(
(*l122++ = l119,*l122 = '\0'),(l119 = (--(l111)->l2>=0?(int)(*(unsigned char*
)(l111)->l3++):l150(l111))));}if(l119 == 'e'||l119 == 'E'){((*l122++ = l119,*
l122 = '\0'),(l119 = (--(l111)->l2>=0?(int)(*(unsigned char*)(l111)->l3++):
l150(l111))));if(l119 == '+'||l119 == '-')((*l122++ = l119,*l122 = '\0'),(
l119 = (--(l111)->l2>=0?(int)(*(unsigned char*)(l111)->l3++):l150(l111))));
while(((l88+1)[l119]&04))((*l122++ = l119,*l122 = '\0'),(l119 = (--(l111)->l2
>=0?(int)(*(unsigned char*)(l111)->l3++):l150(l111))));}}}else if(l119!= (-1)
){l131 = l130;if(l119 == '.'){((*l122++ = l119,*l122 = '\0'),(l119 = (--(l111
)->l2>=0?(int)(*(unsigned char*)(l111)->l3++):l150(l111))));if(((l88+1)[l119]
&04))goto l151;}else{if(l118(l135,l119)!= 0)while(l118(l135,l119)!= 0)((*l122
++ = l119,*l122 = '\0'),(l119 = (--(l111)->l2>=0?(int)(*(unsigned char*)(l111
)->l3++):l150(l111))));else((*l122++ = l119,*l122 = '\0'),(l119 = (--(l111)->
l2>=0?(int)(*(unsigned char*)(l111)->l3++):l150(l111))));}}if(l94)l147(l112,
"type = %s, token = `",l133[(int)l131]);l124 = l141(l121);if(l124+l125>77){
l148("\n",l112);(l125 = 0);}else if((l132==l127||l132==l129)&&(l131==l127||
l131==l129)||l121[0] == '='&&l134){l148(" ",l112);l125++;}l148(l121,l112);
l125+= l124;if(l121[l124-1] == '='&&((l88+1)[l119]&010)){l148(" ",l112);l125
++;}if(l94)l147(l112,"'\n");l132 = l131;}l148("\n",l112);if(l93)l140(0);else{
l152(l111);l143(l112);l42(l101);}}}
/* Licensed material, Copyright (c) 1985, University of Utah. */
typedef long unsigned int l1;
typedef l2 l3;
typedef unsigned char l4;
typedef unsigned short int l5;
typedef unsigned int l6;
typedef unsigned long int l7;
typedef l8 char l9;
typedef unsigned char l10;
typedef l8 short int l11;
typedef unsigned short int l12;
typedef l8 int l13;
typedef unsigned int l14;
typedef l8 long int l15;
typedef unsigned long int l16;
typedef l9 l17;
typedef l10 l18;
typedef l11 l19;
typedef l12 l20;
typedef l13 l21;
typedef l14 l22;
typedef l15
l23;
typedef l16 l24;
typedef long int l25;
typedef unsigned long int l26;
typedef long int l27;
typedef unsigned long int l28;
typedef unsigned long int
l29;
typedef unsigned int l30;
typedef unsigned int l31;
typedef unsigned long int l32;
typedef unsigned long int l33;
typedef unsigned int l34;
typedef unsigned long int l35;
typedef long int l36;
typedef long int l37;
typedef int
l38;
typedef struct
{
int l39[2];
} l40;
typedef long int l41;
typedef unsigned long int l42;
typedef unsigned long int l43;
typedef unsigned int l44;
typedef long int l45;
typedef unsigned int l46;
typedef long int l47;
typedef int l48;
typedef int l49;
typedef int l50;
typedef void *l51;
typedef long int l52;
typedef long int
l53;
typedef long int l54;
typedef unsigned long int l55;
typedef unsigned long int l56;
typedef unsigned long int l57;
typedef unsigned long int l58;
typedef long int l59;
typedef long int l60;
typedef long int l61;
typedef unsigned long int l62;
typedef l37 l63;
typedef char *l64;
typedef long int l65;
typedef unsigned int l66;
typedef int l67;
typedef struct
{
int l68;
union
{
unsigned int l69;
char l70
[4];
} l71;
} l72;
typedef struct l73
{
l36 l74;
l72 l75;
} l76;
typedef struct l77
{
l37
l74;
l72 l75;
} l78;
struct l79;
typedef struct l79 l80;
struct l79;
typedef struct
l79 l81;
struct l79;
struct l82;
struct l83;
struct l84;
typedef void l85;
struct
l79
{
int l86;
char *l87;
char *l88;
char *l89;
char *l90;
char *l91;
char *l92;
char *l93;
char *l94;
char *l95;
char *l96;
char *l97;
struct l82 *l98;
struct l79 *l99;
int l100;
int l101;
l36 l102;
unsigned short l103;
l8 char l104;
char l105[1];
l85 *l106;
l37
l107;
struct l83 *l108;
struct l84 *l109;
struct l79 *l110;
void *l111;
l1 l112;
int
l113;
char l114[15 * sizeof(int) - 4 * sizeof(void *) - sizeof(l1)];
};
typedef l3 l115;
typedef l36 l116;
typedef l60 l117;
typedef l76 l118;
extern l81 *l119;
extern l81
*l120;
extern l81 *l121;
extern int l122(l123 char *l124) l125((l126, l127));
extern int l128(l123 char *l129, l123 char *l130) l125((l126, l127));
extern int l131(int
l132,
l123 char *l129, int l133, l123 char *l130) l125((l126, l127));
extern l81 *l134(void);
extern char *l135(char *l136) l125((l126, l127));
extern char *l137(char *
l136) l125((l126, l127));
extern char *l138(l123 char *l139, l123 char *l140) l125((
l126, l127)) l125((l141));
extern int l142(l81 *l143);
extern int l144(l81 *l143);
extern int l145(l81 *l143);
extern l81 *l146(l123 char *l147 l124, l123 char *l147
l148);
extern l81 *l149(l123 char *l147 l124, l123 char *l147 l148, l81 *l147 l143);
extern l81 *l150(int l151, l123 char *l148) l125((l126, l127));
extern l81 *l152(
void *l136, l1 l153, l123 char *l148) l125((l126, l127));
extern l81 *l154(char **l155, l1 *l156) l125((l126, l127));
extern void l157(l81 *l147 l143, char *l147 l158) l125((l126, l127));
extern int l159(l81 *l147 l143, char *l147 l158, int l148, l1 l160)
l125((l126, l127));
extern void l161(l81 *l147 l143, char *l147 l158, l1 l162) l125(
(l126, l127));
extern void l163(l81 *l143) l125((l126, l127));
extern int l164(l81 *
l147 l143,
l123 char *l147 l165, ...);
extern int l166(l123 char *l147 l165, ...);
extern int l167(char *l147 l136, l123 char *l147 l165, ...) l125((l126));
extern int
l168(l81 *l147 l136, l123 char *l147 l165, l3 l169);
extern int l170(l123 char *
l147 l165,
l3 l169);
extern int l171(char *l147 l136, l123 char *l147 l165, l3 l169) l125((l126));
extern int l172(char *l147 l136, l1 l173, l123 char *l147 l165, ...)
l125((l126)) l125((l174(l175, 3, 4)));
extern int l176(char *l147 l136, l1 l173,
l123 char *l147 l165, l3 l169) l125((l126)) l125((l174(l175, 3, 0)));
extern int l177(int l151, l123 char *l147 l178, l3 l169) l125((l174(l175, 2, 0)));
extern int l179(
int l151, l123 char *l147 l178, ...) l125((l174(l175, 2, 3)));
extern int l180(l81 *
l147 l143,
l123 char *l147 l165, ...);
extern int l181(l123 char *l147 l165, ...);
extern int l182(l123 char *l147 l136, l123 char *l147 l165, ...) l125((l126, l127));
extern int l180(l81 *l147 l143, l123 char *l147 l165, ...) l183(""
"__isoc99_fscanf");
extern int l181(l123 char *l147 l165, ...) l183(""
"__isoc99_scanf");
extern int l182(l123 char *l147 l136, l123 char *l147 l165, ...) l183(""
"__isoc99_sscanf") l125((l126, l127));
extern int l184(l81 *l147 l136,
l123 char *l147 l165, l3 l169) l125((l174(l185, 2, 0)));
extern int l186(l123 char *
l147 l165,
l3 l169) l125((l174(l185, 1, 0)));
extern int l187(l123 char *l147 l136,
l123 char *l147 l165, l3 l169) l125((l126, l127)) l125((l174(l185, 2, 0)));
extern int
l184(l81 *l147 l136, l123 char *l147 l165, l3 l169) l183(""
"__isoc99_vfscanf") l125((l174(l185, 2, 0)));
extern int l186(l123 char *l147 l165, l3 l169) l183(""
"__isoc99_vscanf") l125((l174(l185, 1, 0)));
extern int l187(l123 char *l147 l136,
l123 char *l147 l165, l3 l169) l183(""
"__isoc99_vsscanf") l125((l126, l127)) l125((l174(l185, 2, 0)));
extern int l188(l81 *l143);
extern int l189(l81 *l143);
extern int l190(void);
extern int l191(l81 *l143);
extern int l192(void);
extern int l193(l81 *l143);
extern int l194(int l195, l81 *l143);
extern int l196(int l195, l81 *
l143);
extern int l197(int l195);
extern int l198(int l195, l81 *l143);
extern int
l199(int l195, l81 *l143);
extern int l200(int l195);
extern int l201(l81 *l143);
extern int l202(int l203, l81 *l143);
extern char *l204(char *l147 l136, int l160,
l81 *l147 l143);
extern l60 l205(char **l147 l206, l1 *l147 l160, int l207, l81 *l147 l143);
extern l60 l208(char **l147 l206, l1 *l147 l160, int l207, l81 *l147 l143);
extern l60 l209(char **l147 l206, l1 *l147 l160, l81 *l147 l143);
extern int l210(
l123 char *l147 l136, l81 *l147 l143);
extern int l211(l123 char *l136);
extern int
l212(int l195, l81 *l143);
extern l1 l213(void *l147 l214, l1 l162, l1 l160, l81 *l147 l143);
extern l1 l215(l123 void *l147 l214, l1 l162, l1 l160, l81 *l147 l136);
extern l1 l216(void *l147 l214, l1 l162, l1 l160, l81 *l147 l143);
extern l1 l217(
l123 void *l147 l214, l1 l162, l1 l160, l81 *l147 l143);
extern int l218(l81 *l143,
long int l219, int l220);
extern long int l221(l81 *l143);
extern void l222(l81 *
l143);
extern int l223(l81 *l143, l36 l219, int l220);
extern l36 l224(l81 *l143);
extern int l225(l81 *l147 l143, l118 *l147 l74);
extern int l226(l81 *l143, l123
l118 *l74);
extern void l227(l81 *l143) l125((l126, l127));
extern int l228(l81 *
l143) l125((l126, l127));
extern int l229(l81 *l143) l125((l126, l127));
extern void
l230(l81 *l143) l125((l126, l127));
extern int l231(l81 *l143) l125((l126, l127));
extern int l232(l81 *l143) l125((l126, l127));
extern void l233(l123 char *l136);
extern int l234;
extern l123 char *l123 l235[];
extern int l236(l81 *l143) l125((
l126, l127));
extern int l237(l81 *l143) l125((l126, l127));
extern l81 *l238(l123 char *l239, l123 char *l148);
extern int l240(l81 *l143);
extern char *l241(char *
l136) l125((l126, l127));
extern void l242(l81 *l143) l125((l126, l127));
extern int
l243(l81 *l143) l125((l126, l127));
extern void l244(l81 *l143) l125((l126, l127));
extern int l245(l81 *);
extern int l246(l81 *, int);
typedef char *l247;
typedef int
l248;
typedef char l249;
typedef char *l250;
extern l250 l251();
extern long l252();
typedef union
{
long l253;
double l254;
} l255;
extern char *l256();
l250 l251(l257) int l257;
{
l255 *l258;
if ((l258 = (l255 *)l256((unsigned)(l257 + sizeof(l255)))) <=
0)
{
l164(l121, "\nNo Space in heap! %d bytes requested.\n", l257);
l259(-1);
}
l258
->l253 = (long)l257;
return (l250)(l258 + 1);
}
long l252(l260) l250 l260;
{
return ((
l255 *)l260 -
1)
->l253;
}
l261(l260) l250 l260;
{
if (l260)
l262((char *)((l255 *)l260 - 1));
}
/*
* symtab.c - Symbol Table package routines.
* ( Descriptions in file symtab.h .)
*
* Author: Russ Fish
* Computer Science Dept.
* University of Utah
* Date: 3 September 1981
*/
#include "misc.h"
#include "symtab.h"
/*****************************************************************
* TAG( new_symbol )
*/
id * /* Constructor. */
new_symbol( sym_name, table )
string sym_name;
hash_table * table;
{
id * ret, * * slot;
/* Allocate id node and link into symbol table at hashed location. */
ret = NEW_1( id );
slot = hash( sym_name, table );
ADD( ret, *slot );
ret->var_name = sym_name; /* Link to name string from id. */
ret->var_value = NULL; /* No value cell or fn ptr yet. */
return( ret );
}
/*****************************************************************
* TAG( find_symbol )
*/
id * /* Locator, NULL if not found. */
find_symbol( sym_name, table )
string sym_name;
hash_table * table;
{
register id * sym; /* Symbol list traversal ptr. */
/* Search list to which symbol hashes. */
TRACE( sym, *hash( sym_name, table ) )
{
/* Break out of search loop when matching name is found. */
if ( strcmp( sym_name, sym->var_name ) == 0 ) break;
} /* sym is NULL if trace loop exits. */
return( sym );
}
/*****************************************************************
* TAG( new_hash_table )
*/
hash_table * /* Constructor. */
new_hash_table( n_entries )
int n_entries;
{
hash_table * ret;
id ** ent; /* Entries of table are bases of id lists. */
int i;
ret = NEW( hash_table, sizeof( hash_table ) + n_entries * sizeof( id * ) );
ret->hash_size = n_entries; /* Remember the size, for hash comp. */
for ( i = 0, ent = & ret->hash_id[0]; /* Clear the entries. */
i < n_entries;
i++ )
*ent++ = NULL; /* Empty list pointers. */
return( ret );
}
/*****************************************************************
* TAG( hash )
*/
id * * /* Hashing algorithm, returns ptr to base of an id list in table. */
hash( sym_name, table )
string sym_name;
hash_table * table;
{
register char * c;
register int i, n, hash_val;
/* Hash is the total of the character codes, modulo number of entries. */
for ( i = 0, n = strlen( sym_name ), c = (char *)sym_name, hash_val = 0;
i < n;
i++ )
hash_val += *c++;
return( & table->hash_id[ hash_val % table->hash_size ] );
}
/*****************************************************************
* TAG( ld_table )
*
* Links a vector of already initialiazed id's into a hash table.
* NULL var_name terminates the vector.
*/
ld_table( id_vec, table )
id id_vec[];
hash_table * table;
{
id * sym; /* Vector traversal ptr. */
id * * slot;
for ( sym = & id_vec[0]; sym->var_name != NULL; sym++ )
{
/* Link id node into symbol table at hashed location. */
slot = hash( sym->var_name, table );
ADD( sym, *slot );
}
}
/*****************************************************************
* TAG( fr_hash_table )
*
* Dispose of a hash table.
*/
fr_hash_table( table )
hash_table * table;
{
id ** ent; /* Entries of table are bases of id lists. */
id * ids;
int i;
for ( i = 0, ent = & table->hash_id[0]; /* Clear the entries. */
i < table->hash_size;
i++, ent++ )
if ( ids = *ent )
FREE_LIST( ids );
FREE( table );
}
/*
* symtab.h - Declarations for using Symbol Table package.
*
* Author: Russ Fish
* Computer Science Dept.
* University of Utah
* Date: 28 August 1981
*/
/*****************************************************************
* TAG( symtab )
*
* Simple symbol table package. Hash on name string gives buckets within
* hash table, which are bases of lists of id's, rather than reprobing
* within table. Multiple dictionaries are supported.
*/
#ifndef _SYM_TAB /* Only once. */
#define _SYM_TAB
#include "list.h" /* Needs list package. */
/*****************************************************************
* TAG( id )
*
* id - Identifier datatype.
*/
typedef struct _id id;
struct _id
{
TLISTLINKS(id); /* Linked lists within hash buckets. */
string var_name; /* Character string name of id. */
address var_value; /* Ptr to value of variable id. */
};
/*****************************************************************
* TAG( new_symbol find_symbol )
*/
extern id *
new_symbol(); /* Constructor. */
/* ( sym_name, table )
* string sym_name;
* hash_table * table;
*/
extern id *
find_symbol(); /* Locator, NULL if not found. */
/* ( sym_name, table )
* string sym_name;
* hash_table * table;
*/
/*****************************************************************
* TAG( hash_table new_hash_table hash )
*
* Datatype for hash dictionaries.
*/
typedef struct
{
int hash_size; /* Number of entries in table. */
id * hash_id[1]; /* Base of id list on entry. */
}
hash_table;
extern hash_table *
new_hash_table(); /* Constructor, returns cleared table. */
/* ( n_entries )
* int n_entries;
*/
extern id * *
hash(); /* Hashing algorithm, returns ptr to base of an id list in table. */
/* ( sym_name, table )
* string sym_name;
* hash_table * table;
*/
/*****************************************************************
* TAG( ld_table )
*
* Links a vector of already initialiazed id's into a hash table.
* NULL var_name terminates the vector.
*/
extern
ld_table();
/* ( id_vec, table )
* id id_vec[];
* hash_table * table;
*/
/*****************************************************************
* TAG( fr_hash_table )
*
* Dispose of a hash table.
*/
extern
fr_hash_table();
/* ( table )
* hash_table * table;
*/
/* Macros to aid in initializing symbol vectors. */
#define NULLS NULL,NULL
#define VAR_SYM(name_string,var_name) { NULLS, name_string,&var_name, NULL }
#define FN_SYM(name_string,fn_name) { NULLS, name_string, NULL, fn_name }
#endif _SYM_TAB
'''
Author: your name
Date: 2021-06-21 14:52:24
LastEditTime: 2021-06-22 12:08:31
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath: \evm-store\tools\modules\file-manager\main.py
'''
import os
import shutil
import pprint
import json
from fs.osfs import OSFS
from fs import open_fs
from fs.walk import Walker
disk_root = "D:\\projects\\scriptiot\\evm_app_store_files"
class FileManager(object):
def __init__(self) -> None:
pass
'''
@description: 根据前端传递的路径参数,获取该路径的目录以及文件信息,文件类别,可以看做是一个盘符
@param {*} self
@return {*}
'''
def initialize(self):
'''
disks: {
files: {driver: "local"},
images: {driver: "local"}
}
lang: "en"
leftDisk: null
rightDisk: null
windowsConfig: 2
'''
result = {
"disks": {},
"lang": "zh",
"leftDisk": None,
"rightDisk": None,
"windowsConfig": 1
}
# 这里需要过滤,有些目录只能管理员才能查看
for d in os.listdir(disk_root):
if os.path.isdir(os.sep.join([disk_root, d])):
result["disks"].update({
d: { "driver": "local" }
})
return result
'''
@description: 获取当前类别的目录信息
@param {*} self
@return {*}
'''
def content(self, disk, target_path='/'):
'''
目录信息结构体:
{
basename: "docs"
dirname: ""
path: "docs"
timestamp: 1556821372
type: "dir"
},
{
basename: "cars"
dirname: "wallpapers"
path: "wallpapers/cars"
timestamp: 1544277291
type: "dir"
}
文件信息结构体:
{
basename: "alfa.sql"
dirname: "code"
extension: "sql"
filename: "alfa"
path: "code/alfa.sql"
size: 3208
timestamp: 1544277274
type: "file"
}
'''
# disk = "uploads" # disk就是文件根目录,只能以某个目录为根目录,浏览这个目录下面的所有文件
# target_path = None # 就是以disk为根目录的路径
result = {
"directories": [],
"files": []
}
disk_path = os.sep.join([disk_root, disk])
if not os.path.exists(disk_path):
return result
if not os.path.exists(os.path.normpath(os.sep.join([disk_path, target_path]))):
return result
os.chdir(disk_path)
print(os.getcwd())
home_fs = open_fs('.')
print(home_fs.tree())
for file in home_fs.scandir(target_path, namespaces=['details']):
if file.is_dir:
result["directories"].append({
"basename": file.name,
"dirname": os.path.basename(target_path),
"path": os.sep.join([target_path, file.name]),
"timestamp": int(file.raw.get("details").get("modified")),
"type": "dir"
})
else:
fn, ex = os.path.splitext(file.name)
result["files"].append({
"basename": file.name,
"dirname": os.path.basename(target_path),
"extension": ex[1:],
"filename": fn,
"path": os.sep.join([target_path, file.name]),
"size": file.size,
"timestamp": int(file.raw.get("details").get("modified")),
"type": "file"
})
print("//////////////////>>>>>>", file.name, file.size, file.suffix, file.path, dir(file))
# for file in os.listdir(target_path):
# print(">>>>>>>>>>>>>>>", os.getcwd(), os.path.relpath(target_path, os.getcwd()))
# if os.path.isdir(os.sep.join([target_path, file])):
# result["directories"].append({
# "basename": os.path.basename(file),
# "dirname": os.path.basename(target_path),
# "path": os.path.relpath(os.getcwd(), target_path),
# "timestamp": int(os.path.getatime(os.sep.join([target_path, file]))),
# "type": "dir"
# })
# else:
# fn, ex = os.path.splitext(file)
# result["files"].append({
# "basename": file,
# "dirname": os.path.basename(target_path),
# "extension": ex,
# "filename": fn,
# "path": os.path.relpath(os.getcwd(), os.sep.join([target_path, file])),
# "size": os.path.getsize(os.sep.join([target_path, file])),
# "timestamp": int(os.path.getmtime(os.sep.join([target_path, file]))),
# "type": "file"
# })
# print("file", file)
# for root, dirs, files in os.walk(os.getcwd(), topdown=False):
# for name in dirs:
# print(os.path.join(root, name), name)
# for name in files:
# print(os.path.join(root, name), name)
home_fs.close()
with open("result.json", "w") as f:
json.dump(result, f)
f.write(json.dumps(result, ensure_ascii=True))
pprint.pprint(result)
return result
'''
@description: 获取目录结构树
@param {*} self
@return {*}
'''
def tree(self):
'''
{
basename: "trees"
dirname: "wallpapers/nature"
path: "wallpapers/nature/trees"
props: {
hasSubdirectories: false
}
hasSubdirectories: false
timestamp: 1544277291
type: "dir"
}
'''
target_path = "./"
home_fs = OSFS(os.getcwd())
# 获取当前目录下所有目录、文件、子目录以及子文件的信息。递归获取
for step in home_fs.walk():
print("================>")
print(step.path, step.dirs, step.files, os.path.basename(step.path))
result["directories"].append({
"basename": os.path.basename(step.path),
"dirname": os.path.dirname(step.path),
"path": step.path,
"timestamp": int(os.path.getatime(os.sep.join([target_path, step.path]))),
"type": "dir"
})
for file in step.files:
if file.is_file:
fn, ex = os.path.splitext(file.name)
result["files"].append({
"basename": file.name,
"dirname": os.path.dirname(step.path),
"extension": ex,
"filename": fn,
"path": step.path,
"size": os.path.getsize(os.sep.join([target_path, step.path, file.name])),
"timestamp": int(os.path.getmtime(os.sep.join([target_path, step.path, file.name]))),
"type": "file"
})
print(file.name, step.path)
print("<================")
home_fs.close()
fileManager = FileManager()
if __name__ == "__main__":
'''
python -m memory_profiler example.py
'''
# from memory_profiler import profile
# @profile
# def test():
# pass
result = fileManager.initialize()
print(result)
result = fileManager.content("uploads")
print(result)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment