当前位置: 首页 > news >正文

网站权重如何提高作品集设计

网站权重如何提高,作品集设计,移动手机号码网站,免费建论坛我试图从Linux中的文件夹中读取所有文件和目录#xff0c;其线程为 获取最大文件大小当前目录和当前目录树下的名称。在线程应用程序(linux#xff0c;pthreads)中读取文件大小时出错主线程扫描基本目录查找文件#xff0c;当找到它的目录时#xff0c;会生成一个新线…我试图从Linux中的文件夹中读取所有文件和目录其线程为 获取最大文件大小当前目录和当前目录树下的名称。在线程应用程序(linuxpthreads)中读取文件大小时出错主线程扫描基本目录查找文件当找到它的目录时会生成一个新线程以生成继续扫描的线程。在这一点上线程加入直到最后创建的线程结束。 (我知道这不是最好的方法但它只是一个练习。)问题是它的程序返回错误的结果我不知道为什么。我有以下文件树来测试应用程序下树. (Debug folder under codelite project/workspace)├── [ 4096] dir1│ └── [ 9] arch-dir1.txt├── [ 4096] dir2│ ├── [ 27] arch-dir2.txt│ └── [ 29083] huge├── [ 29053] direxp├── [ 27048] direxp.o└── [ 68] direxp.o.d正如你可以看到当前目录下的最大文件大小是direxp(这个节目)最大文件大小是巨大的运行二进制文件我得到了以下结果dir: .dir: ..arch: direxp.o.dmax dir tree set to: direxp.o.d size: 68arch: direxp.omax file dir set to: direxp.o size: 27048arch: .darch: direxpmax file dir set to: direxp size: 29053dir: dir1th dir: .th dir: ..th arch: arch-dir1.txt thsize: 4096max tree file set to: arch-dir1.txt thsize: 4096dir: dir2th dir: .th dir: ..th arch: arch-dir2.txt thsize: 4096th arch: huge thsize: 4096Highest current directory file:direxp tam:29053 bytes.Highest tree file:arch-dir1.txt tam:4096 bytes.个前缀字符串显示在另一个线程处理的数据。我使用函数readdir(主线程)和readdir_r(衍生线程)来读取目录条目。我认为这可能是麻烦但后来编译程序调用readdir_r在所有线程下并且错误的结果仍然存在。我真的不明白为什么文件大小它返回错误的(4096它在我的文件系统默认的簇大小。那么为什么文件处理为目录能给我一个忙吗 感谢主要功能码#include #include #include #include #include #include #include #include #include using std::cout;using std::cin;using std::endl;#define MAX_PATH 255struct archivo{char nombre[MAX_PATH1];off_t tam;};// thread argsstruct thargs{char nextdir[MAX_PATH1]; // next dirvoid* (*pth)(void*); // pointer to thread functionarchivo* arch; // pointer to archivo};pthread_mutex_t lock PTHREAD_MUTEX_INITIALIZER;int main(int argc, char **argv){char target[MAX_PATH1] {0}; // directorio inicialarchivo grande_dir {{0}},grande_arbol {{0}};// No paramsif (argc 2){if (! getcwd(target,MAX_PATH)){perror(Error en path:);exit(-1);}}if (argc 2)strncpy(target,argv[1],MAX_PATH);if (argc 2){perror(Num params incorrecto);exit(-2);}DIR* midir NULL;// try to open target dirif (! (midir opendir(target))){perror(Error abriendo dir:);exit(-3);}dirent* direntry;//dirent* rentry1 NULL;struct stat estado {0}; // struct needed for desambiguationbool primera true; // control var to initialize the search// read current dir contents//while((readdir_r(midir,direntry,rentry1) 0) rentry1 )while((direntry readdir(midir))){stat(direntry-d_name,estado);// current entry its a fileif (direntry-d_type DT_REG){cout arch: direntry-d_name endl;// init search to find the highest fileif (primera){strncpy(grande_dir.nombre,direntry-d_name,MAX_PATH);grande_dir.tam estado.st_size;strncpy(grande_arbol.nombre,direntry-d_name,MAX_PATH);grande_arbol.tam estado.st_size;primera false;cout max dir tree set to: direntry-d_name size: estado.st_size endl;}// High file sizeif (estado.st_size grande_dir.tam){pthread_mutex_lock(lock);strncpy(grande_dir.nombre,direntry-d_name,MAX_PATH);grande_dir.tam estado.st_size;pthread_mutex_unlock(lock);cout max file dir set to: direntry-d_name size: estado.st_size endl;}}// current entry its a directoryif (direntry-d_type DT_DIR){cout dir: direntry-d_name endl;// check not . or .. dirif ((strcmp(direntry-d_name,.) ! 0) (strcmp(direntry-d_name,..) ! 0)){thargs args {{0}};pthread_t th1;pthread_mutex_lock(lock);sprintf(args.nextdir,%s/%s,target,direntry-d_name);args.arch grande_arbol;args.pth procesadir;pthread_mutex_unlock(lock);// new thread creationpthread_create(th1,NULL,procesadir,args);// main thread waits th1 completionpthread_join(th1, NULL);}}}closedir(midir);pthread_mutex_destroy(lock);cout endl Highest file in current directory file : endl grande_dir.nombre tam: grande_dir.tam bytes. endl;cout endl Highest file in tree: endl grande_arbol.nombre tam: grande_arbol.tam bytes. endl;return 0;}线程函数代码void* procesadir(void* args){thargs* myargs reinterpret_cast(args);DIR* thdir NULL;if ((thdir opendir(myargs-nextdir))){dirent thentry;dirent* rentry NULL;struct stat thstat {0};//while((thentry readdir(thdir)))while((readdir_r(thdir,thentry,rentry) 0) rentry ){stat(thentry.d_name,thstat);if (thentry.d_type DT_REG){cout th arch: thentry.d_name thsize: thstat.st_size endl;if (thstat.st_size myargs-arch-tam){pthread_mutex_lock(lock);memset(myargs-arch-nombre,0,MAX_PATH);strncpy(myargs-arch-nombre,thentry.d_name,MAX_PATH);myargs-arch-tam thstat.st_size;pthread_mutex_unlock(lock);cout max tree file set to: thentry.d_name thsize: thstat.st_size endl;}}if (thentry.d_type DT_DIR){if ((strcmp(thentry.d_name,.) ! 0) (strcmp(thentry.d_name,..) ! 0)){thargs largs {{0}};pthread_t th2;sprintf(largs.nextdir,%s/%s,myargs-nextdir,thentry.d_name);largs.arch myargs-arch;largs.pth myargs-pth;// thread creationpthread_create(th2,NULL,procesadir,args);// current thread waits th2 completionpthread_join(th2, NULL);}cout th dir: thentry.d_name endl;}}closedir(thdir);elseperror(Error abriendo dir en thread:);return 0;}2012-01-26ppk
http://www.sadfv.cn/news/112149/

相关文章:

  • 会展网站的建设情况加强网站人才建设
  • 国外视觉差网站做网站的结论和心得
  • 插画素材网站有哪些wordpress短信登陆
  • 海口网站开发公司上海网页建站
  • 企业为啥要做网站个人备案可以做盈利网站吗
  • php做不了大型网站建设一个网站需要提供什么手续
  • 网站管理与维护wordpress更改主题背景
  • 网站开发语言 微信接口对学院网站建设的建议
  • 域名打不开原来的网站网页开发工作室
  • 做网站需要用到的符号语言做网站多久学会
  • wordpress网站模板下载网站改版计划
  • 资阳视频网站建设深圳做棋牌网站建设哪家公司收费合理
  • 淮安新网站制作企业官网设计图
  • 咋样着做自己的网站网站建设客户需求表
  • 学校网站 源码做网站要注册公司吗
  • 做一个网站如何做天津市政建设集团有限公司网站
  • 那些平台可以给网站做外链做网站 编程语言
  • 内蒙古自治区住房和城乡建设厅网站广州市又恢复48小时核酸检测
  • 网站密码怎么做去哪儿网站上做民宿需要材料
  • 建网站合同做网站 域名如何要回
  • 站长网站推广ui一般用什么软件做
  • 东莞网站优化费用帝国网站后台认证码错误
  • 企业网站建设找智恒网络在线做头像网站
  • 电子商务大型网站建设asp网站域名
  • 如何做网站的版块规划一个小网站一般多少钱
  • 做网站头视频惠州市建设工程交易中心网站
  • 如何进行电子商务网站建设规划wordpress文章修改大小
  • 企业网站网上推广的途径商业机构的网站是什么
  • asp网站建设公司工作总结写作
  • 做网站没流量网站做彩票