@@ -52,12 +52,8 @@ private function getFilePath($keyword, $skip = false) {
52
52
* Skip Create Sub Folders;
53
53
*/
54
54
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 ())) {
61
57
throw new Exception ("PLEASE CHMOD " .$ this ->getPath ()." - 0777 OR ANY WRITABLE PERMISSION! " ,92 );
62
58
}
63
59
}
@@ -76,7 +72,7 @@ function driver_set($keyword, $value = "", $time = 300, $option = array() ) {
76
72
/*
77
73
* Skip if Existing Caching in Options
78
74
*/
79
- if (isset ($ option ['skipExisting ' ]) && $ option ['skipExisting ' ] == true && @ file_exists ($ file_path )) {
75
+ if (isset ($ option ['skipExisting ' ]) && $ option ['skipExisting ' ] == true && file_exists ($ file_path )) {
80
76
$ content = $ this ->readfile ($ file_path );
81
77
$ old = $ this ->decode ($ content );
82
78
$ toWrite = false ;
@@ -91,21 +87,11 @@ function driver_set($keyword, $value = "", $time = 300, $option = array() ) {
91
87
* because first-to-lock wins and the file will exist before the writer attempts
92
88
* to write.
93
89
*/
94
- if ($ toWrite == true && !@ file_exists ($ tmp_path ) && !@ file_exists ($ file_path )) {
90
+ if ($ toWrite == true && !file_exists ($ tmp_path ) && !file_exists ($ file_path )) {
95
91
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 );
109
95
} catch (Exception $ e ) {
110
96
// miss cache
111
97
$ written = false ;
@@ -117,7 +103,7 @@ function driver_set($keyword, $value = "", $time = 300, $option = array() ) {
117
103
function driver_get ($ keyword , $ option = array ()) {
118
104
119
105
$ file_path = $ this ->getFilePath ($ keyword );
120
- if (!@ file_exists ($ file_path )) {
106
+ if (!file_exists ($ file_path )) {
121
107
return null ;
122
108
}
123
109
@@ -159,19 +145,18 @@ function driver_stats($option = array()) {
159
145
160
146
$ total = 0 ;
161
147
$ removed = 0 ;
162
- $ content = array ();
163
- while ($ file =@readdir ($ dir )) {
148
+ while ($ file =readdir ($ dir )) {
164
149
if ($ file !=". " && $ file !=".. " && is_dir ($ path ."/ " .$ file )) {
165
150
// read sub dir
166
- $ subdir = @ opendir ($ path ."/ " .$ file );
151
+ $ subdir = opendir ($ path ."/ " .$ file );
167
152
if (!$ subdir ) {
168
153
throw new Exception ("Can't read path: " .$ path ."/ " .$ file ,93 );
169
154
}
170
155
171
- while ($ f = @ readdir ($ subdir )) {
156
+ while ($ f = readdir ($ subdir )) {
172
157
if ($ f !=". " && $ f !=".. " ) {
173
158
$ file_path = $ path ."/ " .$ file ."/ " .$ f ;
174
- $ size = @ filesize ($ file_path );
159
+ $ size = filesize ($ file_path );
175
160
$ object = $ this ->decode ($ this ->readfile ($ file_path ));
176
161
177
162
if (strpos ($ f ,". " ) === false ) {
@@ -219,15 +204,15 @@ function driver_clean($option = array()) {
219
204
throw new Exception ("Can't read PATH: " .$ path ,94 );
220
205
}
221
206
222
- while ($ file =@ readdir ($ dir )) {
207
+ while ($ file =readdir ($ dir )) {
223
208
if ($ file !=". " && $ file !=".. " && is_dir ($ path ."/ " .$ file )) {
224
209
// read sub dir
225
210
$ subdir = @opendir ($ path ."/ " .$ file );
226
211
if (!$ subdir ) {
227
212
throw new Exception ("Can't read path: " .$ path ."/ " .$ file ,93 );
228
213
}
229
214
230
- while ($ f = @ readdir ($ subdir )) {
215
+ while ($ f = readdir ($ subdir )) {
231
216
if ($ f !=". " && $ f !=".. " ) {
232
217
$ file_path = $ path ."/ " .$ file ."/ " .$ f ;
233
218
@unlink ($ file_path );
@@ -240,7 +225,7 @@ function driver_clean($option = array()) {
240
225
241
226
function driver_isExisting ($ keyword ) {
242
227
$ file_path = $ this ->getFilePath ($ keyword ,true );
243
- if (!@ file_exists ($ file_path )) {
228
+ if (!file_exists ($ file_path )) {
244
229
return false ;
245
230
} else {
246
231
// check expired or not
0 commit comments