From c73e775903fdb86f1018057907880e4ed63b67a7 Mon Sep 17 00:00:00 2001 From: jim Date: Sun, 12 Nov 2006 18:42:56 +0000 Subject: [PATCH] updated large file support in dirlist.lib.php to support getting file size of files over 2GB on Windows systems, hopefully getting rid of php's filesize() limitations once and for all. git-svn-id: file:///Users/jimeh/Desktop/dlist/trunk@38 a5845835-ea0f-0410-a762-dd0bfe9bfde8 --- index.php | 2 +- libs/dirlist.lib.php | 27 +++++++++++++-------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/index.php b/index.php index 75a72f7..b4bac73 100644 --- a/index.php +++ b/index.php @@ -2,7 +2,7 @@ /* - dList v2.2.7 beta + dList v2.2.8 beta Copyright © 2006 Jim Myhrberg. zynode@gmail.com diff --git a/libs/dirlist.lib.php b/libs/dirlist.lib.php index 6942e98..18ffc2c 100644 --- a/libs/dirlist.lib.php +++ b/libs/dirlist.lib.php @@ -4,7 +4,7 @@ class dirList { /* - Class: dirList v2.2 beta + Class: dirList v2.2.1 beta Copyright © 2006 Jim Myhrberg. zynode@gmail.com @@ -227,29 +227,28 @@ class dirList { } function get_large_filesize ($file) { - $system = $this->system_info(); - if ( $system == 'unix' ) { + if ( $this->system_info() == 'unix' ) { exec('ls -l "'.str_replace('"', '\"', $file).'"', $details, $result); - if ( $result == 0 ) { - foreach( $details as $key => $value ) { - preg_match('/.*?([0-9]{10,32}).*/i', $value, $size); - return (!empty($size[1])) ? $size[1] : 'LARGE' ; - } - } else { - return 'LARGE'; - } } else { - return 'LARGE'; + $file = str_replace('/', '\\', $file); + exec('dir /-C "'.str_replace('"', '\"', $file).'"', $details, $result); } + if ( $result == 0 ) { + foreach( $details as $key => $value ) { + if ( preg_match('/.*?([0-9]{10,32}).*?'.preg_quote(basename($file), '/').'/i', $value, $size) ) { + return $size[1]; + } + } + } + return 'LARGE'; } function system_info () { - if ( stripos('windows', $_SERVER['SERVER_SOFTWARE']) ) { + if ( preg_match('/windows|win32|win64/i', $_SERVER['SERVER_SOFTWARE']) ) { return 'windows'; } else { return 'unix'; } - } function getOwner ($item) {