@@ -52,12 +52,8 @@ private function getFilePath($keyword, $skip = false) {
5252 * Skip Create Sub Folders;
5353 */
5454 if ($ skip == false ) {
55- //if it doesn't exist, I can't create it, and nobody beat me to creating it:
56- if (!@is_dir ($ path ) && !@mkdir ($ path ,$ this ->__setChmodAuto ()) && !@is_dir ($ path )) {
57- throw new Exception ("PLEASE CHMOD " .$ this ->getPath ()." - 0777 OR ANY WRITABLE PERMISSION! " ,92 );
58- }
59- //if it does exist (after someone beat me to it, perhaps), but isn't writable or fixable:
60- if (@is_dir ($ path ) && !is_writeable ($ path ) && !@chmod ($ path ,$ this ->__setChmodAuto ())) {
55+ if (!file_exists ($ path )) {
56+ if (!mkdir ($ path ,$ this ->__setChmodAuto ())) {
6157 throw new Exception ("PLEASE CHMOD " .$ this ->getPath ()." - 0777 OR ANY WRITABLE PERMISSION! " ,92 );
6258 }
6359 }
@@ -76,7 +72,7 @@ function driver_set($keyword, $value = "", $time = 300, $option = array() ) {
7672 /*
7773 * Skip if Existing Caching in Options
7874 */
79- if (isset ($ option ['skipExisting ' ]) && $ option ['skipExisting ' ] == true && @ file_exists ($ file_path )) {
75+ if (isset ($ option ['skipExisting ' ]) && $ option ['skipExisting ' ] == true && file_exists ($ file_path )) {
8076 $ content = $ this ->readfile ($ file_path );
8177 $ old = $ this ->decode ($ content );
8278 $ toWrite = false ;
@@ -91,21 +87,11 @@ function driver_set($keyword, $value = "", $time = 300, $option = array() ) {
9187 * because first-to-lock wins and the file will exist before the writer attempts
9288 * to write.
9389 */
94- if ($ toWrite == true && !@ file_exists ($ tmp_path ) && !@ file_exists ($ file_path )) {
90+ if ($ toWrite == true && !file_exists ($ tmp_path ) && !file_exists ($ file_path )) {
9591 try {
96- $ f = @fopen ($ tmp_path , "c " );
97- if ($ f ) {
98- if (flock ($ f ,LOCK_EX | LOCK_NB )) {
99- $ written = ($ written && fwrite ($ f , $ data ));
100- $ written = ($ written && fflush ($ f ));
101- $ written = ($ written && flock ($ f , LOCK_UN ));
102- } else {
103- //arguably the file is being written to so the job is done
104- $ written = false ;
105- }
106- $ written = ($ written && @fclose ($ f ));
107- $ written = ($ written && @rename ($ tmp_path ,$ file_path ));
108- }
92+ $ f = fopen ($ file_path , "w+ " );
93+ fwrite ($ f , $ data );
94+ fclose ($ f );
10995 } catch (Exception $ e ) {
11096 // miss cache
11197 $ written = false ;
@@ -117,7 +103,7 @@ function driver_set($keyword, $value = "", $time = 300, $option = array() ) {
117103 function driver_get ($ keyword , $ option = array ()) {
118104
119105 $ file_path = $ this ->getFilePath ($ keyword );
120- if (!@ file_exists ($ file_path )) {
106+ if (!file_exists ($ file_path )) {
121107 return null ;
122108 }
123109
@@ -159,19 +145,18 @@ function driver_stats($option = array()) {
159145
160146 $ total = 0 ;
161147 $ removed = 0 ;
162- $ content = array ();
163- while ($ file =@readdir ($ dir )) {
148+ while ($ file =readdir ($ dir )) {
164149 if ($ file !=". " && $ file !=".. " && is_dir ($ path ."/ " .$ file )) {
165150 // read sub dir
166- $ subdir = @ opendir ($ path ."/ " .$ file );
151+ $ subdir = opendir ($ path ."/ " .$ file );
167152 if (!$ subdir ) {
168153 throw new Exception ("Can't read path: " .$ path ."/ " .$ file ,93 );
169154 }
170155
171- while ($ f = @ readdir ($ subdir )) {
156+ while ($ f = readdir ($ subdir )) {
172157 if ($ f !=". " && $ f !=".. " ) {
173158 $ file_path = $ path ."/ " .$ file ."/ " .$ f ;
174- $ size = @ filesize ($ file_path );
159+ $ size = filesize ($ file_path );
175160 $ object = $ this ->decode ($ this ->readfile ($ file_path ));
176161
177162 if (strpos ($ f ,". " ) === false ) {
@@ -219,15 +204,15 @@ function driver_clean($option = array()) {
219204 throw new Exception ("Can't read PATH: " .$ path ,94 );
220205 }
221206
222- while ($ file =@ readdir ($ dir )) {
207+ while ($ file =readdir ($ dir )) {
223208 if ($ file !=". " && $ file !=".. " && is_dir ($ path ."/ " .$ file )) {
224209 // read sub dir
225210 $ subdir = @opendir ($ path ."/ " .$ file );
226211 if (!$ subdir ) {
227212 throw new Exception ("Can't read path: " .$ path ."/ " .$ file ,93 );
228213 }
229214
230- while ($ f = @ readdir ($ subdir )) {
215+ while ($ f = readdir ($ subdir )) {
231216 if ($ f !=". " && $ f !=".. " ) {
232217 $ file_path = $ path ."/ " .$ file ."/ " .$ f ;
233218 @unlink ($ file_path );
@@ -240,7 +225,7 @@ function driver_clean($option = array()) {
240225
241226 function driver_isExisting ($ keyword ) {
242227 $ file_path = $ this ->getFilePath ($ keyword ,true );
243- if (!@ file_exists ($ file_path )) {
228+ if (!file_exists ($ file_path )) {
244229 return false ;
245230 } else {
246231 // check expired or not
0 commit comments