コード例 #1
0
 /**
  * Retrieves the container folder and optionally creates a new folder if required.
  * @param Directory The base path to use
  * @param string The name of the container. Uses the first CONTAINER_NAME_USAGE_LENGTH characters of the string. If the string is smaller, Its get zero-padded.
  * @param bool True to create the folder if it does not exists, false otherwise.
  * @return Directory Returns the requested path with the container components
  */
 protected static function getContainerFolder(\System\IO\Directory $baseFolder, $container, $createIfNotExists)
 {
     $containerNameUsage = self::getContainerNameParts($container);
     $containerNameParts = str_split($containerNameUsage);
     $containerPath = implode(\System\IO\Directory::getSeparator(), $containerNameParts);
     $basePath = new \System\IO\Directory($baseFolder->getCurrentPath() . $containerPath, false);
     if (!$basePath->exists() && $createIfNotExists) {
         $oldMask = umask(0);
         mkdir($basePath->getCurrentPath(), \System\IO\Directory::FULL_ACCESS, true);
         umask($oldMask);
     }
     if (!$basePath->exists()) {
         throw new \System\Error\Exception\FileNotFoundException('Could not create the given folder: ' . $basePath->getCurrentPath());
     }
     return $basePath;
 }
コード例 #2
0
ファイル: APIGen.class.php プロジェクト: Superbeest/Core
 /**
  * Stores the given codeblock to its appropriate file. It appends the block to the end of the file.
  * @param \System\IO\Directory The target base folder
  * @param \ReflectionClass The class whoms definition to store
  * @param string The code to place in the sourcefile.
  */
 private static final function storeToFile(\System\IO\Directory $targetFolder, \ReflectionClass $class, $code)
 {
     //store the contents to a file
     $targetFolderStr = \System\IO\Directory::getPath($targetFolder->getCurrentPath(true) . strtolower($class->getNamespaceName()) . \System\IO\Directory::getSeparator());
     if (!file_exists($targetFolderStr)) {
         mkdir($targetFolderStr, 0777, true);
     }
     $targetFileName = $targetFolderStr . basename($class->getFileName());
     file_put_contents($targetFileName, $code, LOCK_EX | FILE_APPEND);
 }