上次写了个windows tail,发在看雪无人问津,哎,希望这次这个不会:(
这个windows du功能和linux下的du差不多,只是没有把命令行写全,要想写全的,自己下个getopt,修改下参数,我这个是方便自己用的:)
另外本版有人说坛子里没人讲基础的东西,我想基础的东西需要自己琢磨,这个代码应该有些基础的东西可以学,希望给新手提供点基础的东西:)
而且这个工具对某些人应该有很大的帮助
用法: 1 wdu :输出当前目录的文件数,目录数,文件大小等信息
2 wdu somedir 输出目录somedir的文件数,目录数,文件大小等信息
eg:
C:/projects/encrypt>wdu
wdu (Windows du) by aker, version 0.1
1 dirs 64 files 3536.85 K 3.45 M
编译环境:cl + xpsp2
主要使用的一些基础的东西:
1 模板库中:queue,list
2 windows目录查询函数
{// 流程
WIN32_FIND_DATA wfd;
TCHAR szFind[MAX_PATH]; // 遍历路径
。。。。设置要查询的路径。。。。
HANDLE hDiskSearch = FindFirstFile(szFind, &wfd);
.....
FindNextFile(hDiskSearch, &wfd);
.....
FindClose(hDiskSearch); // 关闭查找句柄
}
3 递归调用
具体看代码:
/**/
/*
2007-6-24 1:30
一个windows版的du...
by: aker
编译:cl du.cpp /EHsc
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#include
<
windows.h
>
#include
<
stdio.h
>
#include
<
queue
>
#include
<
list
>
#include
<
iostream
>
using
namespace
std;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#pragma
comment(lib,"user32")
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
class
item
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
...
{
public:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
item()...{};
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
item(char *str)...{
if(str != NULL) strcpy(path,str);};
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
char* getitem() ...{
return path;}
这个windows du功能和linux下的du差不多,只是没有把命令行写全,要想写全的,自己下个getopt,修改下参数,我这个是方便自己用的:)
另外本版有人说坛子里没人讲基础的东西,我想基础的东西需要自己琢磨,这个代码应该有些基础的东西可以学,希望给新手提供点基础的东西:)
而且这个工具对某些人应该有很大的帮助
用法: 1 wdu :输出当前目录的文件数,目录数,文件大小等信息
2 wdu somedir 输出目录somedir的文件数,目录数,文件大小等信息
eg:
C:/projects/encrypt>wdu
wdu (Windows du) by aker, version 0.1
1 dirs 64 files 3536.85 K 3.45 M
编译环境:cl + xpsp2
主要使用的一些基础的东西:
1 模板库中:queue,list
2 windows目录查询函数
{// 流程
WIN32_FIND_DATA wfd;
TCHAR szFind[MAX_PATH]; // 遍历路径
。。。。设置要查询的路径。。。。
HANDLE hDiskSearch = FindFirstFile(szFind, &wfd);
.....
FindNextFile(hDiskSearch, &wfd);
.....
FindClose(hDiskSearch); // 关闭查找句柄
}
3 递归调用
具体看代码:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)