Linux 下檔案操作

2021-05-23 07:07:58 字數 3816 閱讀 9818

#include

#include

#include

#include

#include

#include

#include

#include

#include

#define s 100

void treedisplay();

void treecreat();

void filecreatopen();

void fileread(char pathname);

void filewrite(char pathname);

void treeopen();

void treeback();

long treefilecopy(char copybuf,char copyname);

void treefilepaste(int len,char pastebuf,char copyname);

void treedelete();

void filedelete();

void treefileproperty();

void displayproperty();

void modifypurview(char pathname);

void treefilerename();

void changesize();

main()

break;

case 2:break;

case 3:break;

case 4:break;

case 5:break;

case 6:

void treecreat()

}while(fd==-1);

}void fileread(char pathname)

fclose(fp);

}void filewrite(char pathname)

fclose(fp);

}void treeopen()

else    

}void treeback()

long treefilecopy(char copybuf,char copyname)

stat(copyname,&buf);

size=buf.st_size;

read(fd,copybuf,size);

return  size;

}void treedelete()

else    

}void filedelete()

else    

}void treefileproperty()

break;

case 2:break;

case 3:break;

case 4:break;

}}while(cord<=3);

}void displayproperty()

stat(pathname,&buf);

mode=buf.st_mode;

printf("%-10s","mode:");

printf("%10s","read");printf("%10s","write");

printf("%10s","execute/n");printf("%10s","all user");

if((mode&0400)==s_irusr)printf("%10s","true");

else printf("%10s","false");

if((mode&0200)==s_iwusr)printf("%10s","true");

else printf("%10s","false");

if((mode&0100)==s_ixusr)printf("%10s","true/n");

else printf("%10s","false/n");

printf("%10s","group");

if((mode&040)==s_irgrp)printf("%10s","true");

else printf("%10s","false");

if((mode&020)==s_iwgrp)printf("%10s","true");

else printf("%10s","false");

if((mode&010)==s_ixgrp)printf("%10s","true/n");

else printf("%10s","false/n");

printf("%10s","other user");

if((mode&04)==s_iroth)printf("%10s","true");

else printf("%10s","false");

if((mode&02)==s_iwoth)printf("%10s","true");

else printf("%10s","false");

if((mode&01)==s_ixoth)printf("%10s","true/n");

else printf("%10s","false/n");

printf("sizeld/n",buf.st_size);

printf("blk sizeld/n",buf.st_blksize);

printf("modify the purview?(y/n)");

scanf("%c",&choose);scanf("%c",&choose);

if(choose=='y')modifypurview(pathname);

}void modifypurview(char pathname)

printf("all user write?(y/n)");

scanf("%c",&choose);scanf("%c",&choose);

if(choose=='y')

printf("all user execute?(y/n)");

scanf("%c",&choose);scanf("%c",&choose);

if(choose=='y')

printf("group read?(y/n)");

scanf("%c",&choose);scanf("%c",&choose);

if(choose=='y')

printf("group write?(y/n)");

scanf("%c",&choose);scanf("%c",&choose);

if(choose=='y')

printf("group execute?(y/n)");

scanf("%c",&choose);scanf("%c",&choose);

if(choose=='y')

printf("other user read?(y/n)");

scanf("%c",&choose);scanf("%c",&choose);

if(choose=='y')

printf("other user write?(y/n)");

scanf("%c",&choose);scanf("%c",&choose);

if(choose=='y')

printf("other user execute?(y/n)");

scanf("%c",&choose);scanf("%c",&choose);

if(choose=='y')

if(!c)chmod(pathname,c);

displayproperty();

}void treefilerename()

else    

}void changesize()

Linux下檔案操作

1.linux下檔案操作的途徑 1 通過底層檔案系統來實現,要求熟悉底層檔案系統的結構,並且編寫大量 來完成 2 通過呼叫shell來完成,訪問shell介面,但shell返回的資訊不便於程式的分析 3 通過系統呼叫來實現,能夠完成相應的功能,並且返回足夠的資訊 2.linux下檔案操作的方式 1 ...

Linux下檔案操作

1.linux下檔案操作的途徑 1 通過底層檔案系統來實現,要求熟悉底層檔案系統的結構,並且編寫大量 來完成 2 通過呼叫shell來完成,訪問shell介面,但shell返回的資訊不便於程式的分析 3 通過系統呼叫來實現,能夠完成相應的功能,並且返回足夠的資訊 2.linux下檔案操作的方式 1 ...

linux下檔案操作

fopen fclose fwrite fread 下文簡稱 前者 與open close write read 下文簡稱 後者 的區別和各自的使用 區別 1.前者是c標準i o庫函式,後者位於c標準庫的i o緩衝區的底層稱為無緩衝i o 2.前者是c標準的一部分,而後者是unix標準的一部分,在所...