@@ -134,9 +134,13 @@ public function streamOpen($fileName, $mode = 'w+', $chmod = 0666)
134
134
ini_set ('auto_detect_line_endings ' , 1 );
135
135
}
136
136
137
- @chdir ($ this ->_cwd );
137
+ if ($ this ->_cwd ) {
138
+ @chdir ($ this ->_cwd );
139
+ }
138
140
$ this ->_streamHandler = @fopen ($ fileName , $ mode );
139
- @chdir ($ this ->_iwd );
141
+ if ($ this ->_iwd ) {
142
+ @chdir ($ this ->_iwd );
143
+ }
140
144
if ($ this ->_streamHandler === false ) {
141
145
throw new Exception ('Error write to file ' . $ this ->getFilteredPath ($ fileName ));
142
146
}
@@ -365,7 +369,9 @@ public function rmdir($dir, $recursive = false)
365
369
@chdir ($ this ->_cwd );
366
370
}
367
371
$ result = self ::rmdirRecursive ($ dir , $ recursive );
368
- @chdir ($ this ->_iwd );
372
+ if ($ this ->_iwd ) {
373
+ @chdir ($ this ->_iwd );
374
+ }
369
375
return $ result ;
370
376
}
371
377
@@ -510,7 +516,9 @@ protected function _IsValidSource($src)
510
516
protected function _isFilenameWriteable ($ filename )
511
517
{
512
518
$ error = false ;
513
- @chdir ($ this ->_cwd );
519
+ if ($ this ->_cwd ) {
520
+ @chdir ($ this ->_cwd );
521
+ }
514
522
if (file_exists ($ filename )) {
515
523
if (!is_writeable ($ filename )) {
516
524
$ error = "File ' {$ this ->getFilteredPath ($ filename )}' isn't writeable " ;
@@ -521,7 +529,9 @@ protected function _isFilenameWriteable($filename)
521
529
$ error = "Folder ' {$ this ->getFilteredPath ($ folder )}' isn't writeable " ;
522
530
}
523
531
}
524
- @chdir ($ this ->_iwd );
532
+ if ($ this ->_iwd ) {
533
+ @chdir ($ this ->_iwd );
534
+ }
525
535
526
536
if ($ error ) {
527
537
throw new Varien_Io_Exception ($ error );
@@ -555,29 +565,41 @@ protected function _checkSrcIsFile($src)
555
565
*/
556
566
public function filePutContent ($ filename , $ src )
557
567
{
558
- @chdir ($ this ->_cwd );
568
+ if ($ this ->_cwd ) {
569
+ @chdir ($ this ->_cwd );
570
+ }
559
571
$ result = @file_put_contents ($ filename , $ src );
560
- chdir ($ this ->_iwd );
572
+ if ($ this ->_iwd ) {
573
+ chdir ($ this ->_iwd );
574
+ }
561
575
562
576
return $ result ;
563
577
}
564
578
565
579
public function fileExists ($ file , $ onlyFile = true )
566
580
{
567
- @chdir ($ this ->_cwd );
581
+ if ($ this ->_cwd ) {
582
+ @chdir ($ this ->_cwd );
583
+ }
568
584
$ result = file_exists ($ file );
569
585
if ($ result && $ onlyFile ) {
570
586
$ result = is_file ($ file );
571
587
}
572
- @chdir ($ this ->_iwd );
588
+ if ($ this ->_iwd ) {
589
+ @chdir ($ this ->_iwd );
590
+ }
573
591
return $ result ;
574
592
}
575
593
576
594
public function isWriteable ($ path )
577
595
{
578
- @chdir ($ this ->_cwd );
596
+ if ($ this ->_cwd ) {
597
+ @chdir ($ this ->_cwd );
598
+ }
579
599
$ result = is_writeable ($ path );
580
- @chdir ($ this ->_iwd );
600
+ if ($ this ->_iwd ) {
601
+ @chdir ($ this ->_iwd );
602
+ }
581
603
return $ result ;
582
604
}
583
605
@@ -634,9 +656,13 @@ public function checkAndCreateFolder($folder, $mode = 0777)
634
656
*/
635
657
public function rm ($ filename )
636
658
{
637
- @chdir ($ this ->_cwd );
659
+ if ($ this ->_cwd ) {
660
+ @chdir ($ this ->_cwd );
661
+ }
638
662
$ result = @unlink ($ filename );
639
- @chdir ($ this ->_iwd );
663
+ if ($ this ->_iwd ) {
664
+ @chdir ($ this ->_iwd );
665
+ }
640
666
return $ result ;
641
667
}
642
668
@@ -649,9 +675,13 @@ public function rm($filename)
649
675
*/
650
676
public function mv ($ src , $ dest )
651
677
{
652
- chdir ($ this ->_cwd );
678
+ if ($ this ->_cwd ) {
679
+ chdir ($ this ->_cwd );
680
+ }
653
681
$ result = @rename ($ src , $ dest );
654
- chdir ($ this ->_iwd );
682
+ if ($ this ->_iwd ) {
683
+ chdir ($ this ->_iwd );
684
+ }
655
685
return $ result ;
656
686
}
657
687
@@ -664,9 +694,13 @@ public function mv($src, $dest)
664
694
*/
665
695
public function cp ($ src , $ dest )
666
696
{
667
- @chdir ($ this ->_cwd );
697
+ if ($ this ->_cwd ) {
698
+ @chdir ($ this ->_cwd );
699
+ }
668
700
$ result = @copy ($ src , $ dest );
669
- @chdir ($ this ->_iwd );
701
+ if ($ this ->_iwd ) {
702
+ @chdir ($ this ->_iwd );
703
+ }
670
704
return $ result ;
671
705
}
672
706
@@ -682,7 +716,7 @@ public function chmod($filename, $mode)
682
716
if ($ this ->_cwd ) {
683
717
chdir ($ this ->_cwd );
684
718
}
685
- $ result = @chmod ($ filename , $ mode );
719
+ $ result = file_exists ( $ filename ) ? @chmod ($ filename , $ mode ) : false ;
686
720
if ($ this ->_iwd ) {
687
721
chdir ($ this ->_iwd );
688
722
}
0 commit comments