#virtual filesystem module
#version 2.0
defpath(path):i=len(path)-1whilei!=0andpath[i]!="/":i-=1return ("/"+path[0:i],path[i+1:len(path)])ifi!=0else (path[0:i],path[i:len(path)])fstree=["folder",{},"rw-rw-rw-"]dosSyst=("bin","dev","etc","home","lib","media","mnt","opt","proc","root","run","sbin","srv","sys","tmp","usr","var")foriindosSyst:fstree[1][i]=["folder",{},"rw-rw-rw-"]fstree[1]["usr"][1]["users"]=["data","admin bobb\npassword Bobb_56"]fswd=["root"]fsdir=fstree[1]["root"]deldosSystdefcd(name="/root"):#lister les dossiers successifs
globalfswdglobalfsdirifname[0]=="/":#chemin absolu
fswd=[]name=name[1:len(name)]l=[]deb=0foriinrange(len(name)):ifname[i]=="/":l.append(name[deb:i])deb=i+1ifi==len(name)-1:l.append(name[deb:len(name)])fornameinl:ifname=="..":delfswd[-1]else:fswd.append(name)#aller dans le dossier
fsdir=fstreeforiinfswd:iffsdir[1][i][0]=="folder":fsdir=fsdir[1][i]else:print(i,"is not a folder.")delfswd[-1]return"/"+"/".join(fswd)defls(l=""):ifl=="":foriinfsdir[1]:print(i,end="")elifl=="-l":foriinfsdir[1]:print(i,fsdir[1][i][2])print("\n",end="")defpwd():wd="/"+"/".join(fswd)print(wd)returnwddefmkdir(*name):wdDeb="/"+"/".join(fswd)foriinname:i=path(i)cd(wdDeb+i[0])ifnot(i[1]infsdir[1]):fsdir[1][i[1]]=["folder",{},"rw-rw-rw-"]else:print(i[1],"already exists")cd(wdDeb)defsu():l=fstree[1]["usr"][1]["users"][1].split()ifinput("Username: ")==l[l.index("admin")+1]andinput("Password: ")==l[l.index("admin")+3]:print("Welcome")else:print("Authentification failed")deftouch(*name):wdDeb="/"+"/".join(fswd)foriinname:i=path(i)cd(wdDeb+i[0])ifnot(i[1]infsdir[1]):fsdir[1][i[1]]=["file","","rw-rw-rw-"]else:print(i[1],"already exists")cd(wdDeb)defrm(*name,t="file"):wdDeb="/"+"/".join(fswd)foriinname:i=path(i)cd(wdDeb+i[0])iffsdir[1][i[1]][0]==t:delfsdir[1][i[1]]else:print(i[1],"is not a",t)cd(wdDeb)defmv(*args):to="/"+args[-1]name=list(args);name.pop()delargswdDeb="/"+"/".join(fswd)foriinname:i=path(i)cd(wdDeb+i[0])iftoinfsdir[1]:mvData=fsdir[1][i[1]]delfsdir[1][i[1]]cd(wdDeb+to)fsdir[1][i[1]]=mvDataelse:mvData=fsdir[1][i[1]]delfsdir[1][i[1]]fsdir[1][to[1:len(to)]]=mvDatacd(wdDeb)defrmdir(*name):rm(*name,t="folder")defcat(w="",file=""):iffile=="":file=w;w=""wdDeb="/"+"/".join(fswd)file=path(file)cd(wdDeb+file[0])iffsdir[1][file[1]][0]=="file":ifw=="":#aff
print(fsdir[1][file[1]][1])elifw==">":#write
fsdir[1][file[1]][1]=""vartest=Truewhilevartest:try:line=input()fsdir[1][file[1]][1]+=line+"\n"except:vartest=Falseelse:print(file[1],"is not a file")cd(wdDeb)#creation des repertoires
mkdir("Desktop","Documents","Musique","Videos","Images","Documents/Ma_mission")touch("Documents/Ma_mission/Mission.txt")fsdir[1]["Documents"][1]["Ma_mission"][1]["Mission.txt"][1]="Vous avez une mission:\nVous devez parvenir a afficher dans le terminal, de la ou ils sont enregistres, le nom utilisateur de l administrateur ainsi que son mot de passe.\nPour ce faire, vous n avez droit qu a 6 instructions maximum et vous pouvez bien sur aller voir dans le code."
During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:
Ensure the proper functioning of the site (essential cookies); and
Track your browsing to send you personalized communications if you have created a professional account on the site and can be contacted (audience measurement cookies).
With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.