forked from dfar2008/taobaocrm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreatePatch.php
More file actions
55 lines (49 loc) · 1.27 KB
/
createPatch.php
File metadata and controls
55 lines (49 loc) · 1.27 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/*
step1:read file
step2:check whether the line contains "Index:"
step3:parse substring of the line after Index
step4:create folders which does not exist
step5:copy source file to folder created now
step6:close file
*/
$patchFile = "0520.diff";
$path = "D:/CRMONE/home/localhaote/";//
//$path = "E:/release/bin/ecustomer350/www";
$appName = "C3CRM3.0";
$fd = fopen($patchFile,'r');
while(!feof($fd)) {
$line = trim(fgets($fd));
if(substr_count($line,"Index:") > 0) {
$line = trim(substr($line,strpos($line,"Index:") + 6));
$filePath = $line;
//$pos = strpos($line,$appName) + strlen($appName) + 1;
//$filePath = substr($line,$pos);
//$patchPath = substr($line,0,$pos);
$patchPath = $path."/patch";
if(!is_dir($patchPath)) {
if(!mkdir($patchPath)){
echo "patchPath:".$patchPath."<br>";
}
}
$folderArray = explode("/",$filePath);
$length = count($folderArray);
$i = 0;
foreach ($folderArray as $folder) {
$patchPath .= "/".$folder;
$i ++;
if($i == $length) break;
if(!is_dir($patchPath)) {
if(!mkdir($patchPath)){
echo "patchPath:".$patchPath."<br>";
}
}
}
if(is_file($path."/".$line) && copy($path."/".$line,$patchPath)) {
echo 'copy successfully!<br>';
} else {
echo 'copy failed!<br>';
}
}
}
?>