[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/mydms/inc/ -> inc.FileUtils.php (source)

   1  <?php
   2  
   3  function renameFile($old, $new)
   4  {
   5      return rename($old, $new);
   6  }
   7  
   8  function removeFile($file)
   9  {
  10      return unlink($file);
  11  }
  12  
  13  function copyFile($source, $target)
  14  {
  15      return copy($source, $target);
  16  }
  17  
  18  function moveFile($source, $target)
  19  {
  20      if (!copyFile($source, $target))
  21          return false;
  22      return removeFile($source);
  23  }
  24  
  25  function renameDir($old, $new)
  26  {
  27      return rename($old, $new);
  28  }
  29  
  30  function makeDir($path)
  31  {
  32      return mkdir($path, 0755);
  33  }
  34  
  35  function removeDir($path)
  36  {
  37      $handle = opendir($path);
  38      while ($entry = readdir($handle) )
  39      {
  40          if ($entry == ".." || $entry == ".")
  41              continue;
  42          else if (is_dir($path . $entry))
  43          {
  44              if (!removeDir($path . $entry . "/"))
  45                  return false;
  46          }
  47          else
  48          {
  49              if (!unlink($path . $entry))
  50                  return false;
  51          }
  52      }
  53      closedir($handle);
  54      return rmdir($path);
  55  }
  56  
  57  function copyDir($sourcePath, $targetPath)
  58  {
  59      if (mkdir($targetPath, 0777))
  60      {
  61          $handle = opendir($sourcePath);
  62          while ($entry = readdir($handle) )
  63          {
  64              if ($entry == ".." || $entry == ".")
  65                  continue;
  66              else if (is_dir($sourcePath . $entry))
  67              {
  68                  if (!copyDir($sourcePath . $entry . "/", $targetPath . $entry . "/"))
  69                      return false;
  70              }
  71              else
  72              {
  73                  if (!copy($sourcePath . $entry, $targetPath . $entry))
  74                      return false;
  75              }
  76          }
  77          closedir($handle);
  78      }
  79      else
  80          return false;
  81      
  82      return true;
  83  }
  84  
  85  function moveDir($sourcePath, $targetPath)
  86  {
  87      if (!copyDir($sourcePath, $targetPath))
  88          return false;
  89      return removeDir($sourcePath);
  90  }
  91  
  92  //To-DO: fehler abfangen
  93  function getSuitableDocumentDir()
  94  {
  95      $maxVal = 0;
  96      
  97      $handle = opendir($GLOBALS['mydms']->settings->_contentDir);
  98      while ($entry = readdir($handle))
  99      {
 100          if ($entry == ".." || $entry == ".")
 101              continue;
 102          else if (is_dir($GLOBALS['mydms']->settings->_contentDir . $entry))
 103          {
 104              $num = intval($entry);
 105              if ($num >= $maxVal)
 106                  $maxVal = $num+1;
 107          }
 108      }
 109      $name = "" . $maxVal . "";
 110      while (strlen($name) < 5)
 111          $name = "0" . $name;
 112      return $name . "/";
 113  }
 114  ?>


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7