Changeset 2086

Show
Ignore:
Timestamp:
01/22/08 04:08:10 (10 months ago)
Author:
anarcat
Message:

reorder CopyFile? API so that it works like MoveFile? (ie. support multiple files

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • alternc/trunk/bureau/class/m_bro.php

    r2083 r2086  
    453453 
    454454  /** 
     455   * Copy many files from point A to point B 
     456   */ 
     457  function CopyFile($d,$old,$new) { 
     458    global $err; 
     459    $old=$this->convertabsolute($old,0); 
     460    if (!$old) { 
     461      $err->raise("bro",1); 
     462      return false; 
     463    } 
     464    $new=$this->convertabsolute($new,0); 
     465    if (!$new) { 
     466      $err->raise("bro",1); 
     467      return false; 
     468    } 
     469    if ($old==$new) { 
     470      $err->raise("bro",2); 
     471      return false; 
     472    } 
     473    for ($i=0;$i<count($d);$i++) { 
     474      $d[$i]=ssla($d[$i]); // strip slashes if needed 
     475      if (!strpos($d[$i],"/") && file_exists($old."/".$d[$i]) && !file_exists($new."/".$d[$i])) {   
     476        $this->CopyOneFile($old."/".$d[$i],$new); 
     477      } 
     478    } 
     479    return true; 
     480  } 
     481 
     482  /** 
    455483   * Copy a source to a destination by either copying recursively a 
    456484   * directory or by downloading a file with a URL (only http:// is 
    457485   * supported) 
    458    * @param string $name is the application name 
    459486   * @param string $src is the path or URL 
    460487   * @param string $dest is the absolute path inside the users directory 
    461488   * @return boolean false on error 
    462    */ 
    463   function CopyFile($name, $src, $dest) 
     489   * 
     490   * Note that we assume that the inputs have been convertabsolute()'d 
     491   */ 
     492  function CopyOneFile($src, $dest) 
    464493  { 
    465494    global $err; 
     
    521550 
    522551    // Last step // Copy -R 
    523     $src = $this->convertabsolute($src); 
    524     $dest = $this->convertabsolute($dest); 
    525     if (!$src || !$dest) { 
    526       $err->raise("bro",1); 
    527       return false; 
    528     } 
    529552    $src = escapeshellarg($src); 
    530553    $dest = escapeshellarg($dest);