Skip to content

Commit

Permalink
更新
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexchent committed Jan 10, 2020
1 parent c6421aa commit d4c96ec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
26 changes: 4 additions & 22 deletions Helper/cuttxt.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class cutTXT {

protected $message;

// private static $instance;


public function __construct(){
Expand All @@ -51,15 +50,6 @@ public function setPath($path){
return $this->path = $path;
}

public function spilt($fileName, $path, $mode, $size){
$this->setPath($path);
if($mode === 1) {
$this->cutTXTbyNumber($fileName,$size);
}else if($mode === 2){

}
}

/**复制文件,成功返回true,失败返回false
* @param $fileName
* @return array|bool
Expand Down Expand Up @@ -88,9 +78,8 @@ function copyTxt($fileName){
/**将文件分割为$number份
* @param $fileName
* @param $number
* @return int
*/
function cutTXTbyNumber($fileName, $number= 2) {
public static function cutTXTbyNumber($fileName, $number= 2) {

if(file_exists($fileName)){
$count = 1;
Expand All @@ -100,11 +89,8 @@ function cutTXTbyNumber($fileName, $number= 2) {
$fileSize = filesize($fileName);

$size = ceil($fileSize/$number); //进一取整,每个分割块的大小

if($size ==1) {
$this->message['msg'] = "太小不能分割";
$this->message['code'] = -2;
return false;
echo "太小不能分割";die;
}

$pathinfo = pathinfo($fileName);
Expand All @@ -116,17 +102,13 @@ function cutTXTbyNumber($fileName, $number= 2) {
fwrite($handle, fread($fp, $size));
echo $count++;
}else{
$this->message['msg'] = "文件创建失败";
$this->message['code'] = -3;
return false;
echo "文件创建失败\n";
}
}
fclose($fp);
echo "success";
}else{
$this->message['msg'] = "路径或文件名错误";
$this->message['code'] = -1;
return false;
echo "路径或文件名错误";
}

}
Expand Down
1 change: 0 additions & 1 deletion index.php

This file was deleted.

0 comments on commit d4c96ec

Please sign in to comment.