mikespook
懒猫开始新生活——猫眼看世界
本人乃好事之徒,找骂者请自便
PS:如果哪天我不跟坎子找茬了,那我就是死了。^_^
随笔 - 121, 文章 - 0, 评论 - 567, 引用 - 5
PHP写的CVS文件夹清理工具
前些日子有朋友用C#写的这种工具~~我是用TortoiseCVS, 如果不连接服务器无法生成发布文件~~今天CVS服务器没启动,无法继续随即用PHP写一个耍耍~~没什么复杂,递归删除文件夹~~呵呵~
<?
/**/
/*
*
* CVS_Clean.php - Clean CVS folder from the target path.
*
* Copyright (c) 2002-2005 mikespook & swill
*
*/
require_once(
'
File/Find.php
'
);
class
CVS_Clean
{
var $br;
var $slash;
var $path;
var $r;
function CVS_Clean()
{
if
(strtoupper(substr(PHP_OS,
0
,
3
)
==
'
WIN
'
))
{
$
this
->
slash
=
"
\\
"
;
}
else
{
$
this
->
slash
=
"
/
"
;
}
if
(isset($_SERVER[
'
argc
'
]))
{
$
this
->
br
=
"
\n
"
;
}
else
{
$
this
->
br
=
"
<br/>
"
;
}
if
(isset($_GET[
'
path
'
]))
{
$
this
->
path
=
$_GET[
'
path
'
];
}
elseif (isset($_SERVER[
'
argv
'
][
1
]))
{
$
this
->
path
=
$_SERVER[
'
argv
'
][
1
];
}
if
(isset($_GET[
'
r
'
]))
{
$r
=
$_GET[
'
r
'
];
}
elseif (isset($_SERVER[
'
argv
'
][
2
]))
{
$r
=
$_SERVER[
'
argv
'
][
2
];
}
$
this
->
r
=
strtolower($r)
!==
'
-nr
'
;
}
function help()
{
echo
"
I will show you this message that you didn`t input the paramater <dir> or the paramater <dir> is not a valid directory.
"
.$
this
->
br.$
this
->
br;
echo
"
mikespook <mikespook@gmail.com>
"
.$
this
->
br;
echo
"
http://www.xxiyy.com
"
.$
this
->
br.$
this
->
br;
echo
"
Useage: CVS_Clean <dir> [Options]
"
.$
this
->
br;
echo
"
Clean CVS folder from the directory
"
.$
this
->
br.$
this
->
br;
echo
"
<dir>\tThe directory you want to clean without slash (
"
.$
this
->
slash.
"
) at the end.
"
.$
this
->
br;
echo
"
-nr\tDon`t remove the CVS folder recursively.
"
;
}
function run()
{
if
(
!
is_dir($
this
->
path))
{
$
this
->
help();
}
else
{
$
this
->
clean($
this
->
path);
}
}
function clean($path)
{
$finder
=
File_Find::mapTreemultiple($path,
2
);
foreach
($finder
as
$name
=>
$item)
{
if
(is_array($item))
{
if
($
this
->
r)
{
$
this
->
clean($path.$
this
->
slash.$name);
}
if
($name
===
'
CVS
'
)
{
$
this
->
rm($path.$
this
->
slash.$name);
}
}
}
}
function rm($path)
{
$finder
=
File_Find::mapTreemultiple($path,
1
);
foreach
($finder
as
$item)
{
unlink($path.$
this
->
slash.$item);
}
rmdir($path);
}
}
$main
=
new
CVS_Clean();
$main
->
run();
?>
绿色通道:
好文要顶
关注我
收藏该文
与我联系
posted on 2005-08-23 14:16
mikespook
阅读(1008)
评论(1)
编辑
收藏
评论
747763
#1楼
回复
引用
顶
2007-05-15 22:54
|
ysz[未注册用户]
注册用户登录后才能发表评论,请
登录
或
注册
,
返回博客园首页
。
首页
博问
闪存
新闻
园子
招聘
知识库
最新IT新闻
:
·
雷军的宿命:从万籁俱寂到舞台中央的喧嚣
·
中移动为何无缘iPhone:谁都不愿低头
·
NEC收购视频监控公司Global View 85%股份
·
英特尔联合华阳推出车载信息娱乐系统新产
·
PayPal在新加坡地铁试水手机二维码购物
»
更多新闻...
最新知识库文章
:
·
高级编程语言的发展历程
·
如何学习一门新的编程语言?
·
学习不同编程语言的重要性
·
为什么我喜欢富于表达性的编程语言
·
计算机专业的女生为什么要学编程
»
更多知识库文章...
China-pub 2011秋季教材巡展
China-Pub 计算机绝版图书按需印刷服务
导航
博客园
首页
新随笔
联系
订阅
管理
<
2005年8月
>
日
一
二
三
四
五
六
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
公告
昵称:
mikespook
园龄:
7年2个月
粉丝:
4
关注:
0
搜索
常用链接
我的随笔
我的评论
我的参与
最新评论
我的标签
最新随笔
1. 发现不少朋友给我的 blog 链接还是这里
2. 又建立了一个新BLOG
3. 在博客园申请了PHP博客
4. 每日一翻,今日完成
5. 翻译记录
6. 翻译 Debian 软件包简介信息
7. 【收藏】让错误的程序看得出错
8. 魔力论坛2.1.4转PHPWind4.3.2程序
9. 一些PHP相关的数据比较
10. 赋诗一首另杂论点点
随笔分类
编程(40)
(rss)
技术杂谈(41)
(rss)
系统(9)
(rss)
做人与编程(32)
(rss)
随笔档案
2010年6月 (1)
2007年6月 (1)
2006年8月 (3)
2006年7月 (1)
2006年6月 (3)
2006年4月 (2)
2006年3月 (3)
2006年1月 (2)
2005年12月 (2)
2005年11月 (9)
2005年10月 (3)
2005年9月 (6)
2005年8月 (6)
2005年7月 (6)
2005年6月 (8)
2005年5月 (7)
2005年4月 (9)
2005年3月 (4)
2005年2月 (2)
2005年1月 (5)
2004年12月 (7)
相册
linuxsir
jimmy3719's blog
(rss)
赵光的blog
常用
Wallop
好站
codeproject
Joel on Software
PHP Security Consortium
sourceforge
巴蛮子的新破茅屋
(rss)
洪朝貴的首頁
胡旻波的Blog
(rss)
王垠的主页
一风一云的文档
(rss)
朋友
IceSharK - PP.Poet
(rss)
桂枝香在故国晚秋
(rss)
如果有一天...
(rss)
团队
CIO 孵化器
计算机图形学
自己的站
Free Education
mikespook & swill
广州金玉堂饰品批发网
积分与排名
积分 - 183501
排名 - 464
最新评论
阅读排行榜
评论排行榜
推荐排行榜