/** * Set the path for the JSON file. * * @param string $path * * @return self */ public function setPath($path) { if (!$this->files->exists($path) && $this->files->put($path, '{}') === false) { throw new InvalidArgumentException("Could not write to {$path}."); } if (!$this->files->isWritable($path)) { throw new InvalidArgumentException("{$path} is not writable."); } $this->path = $path; return $this; }
/** * Compile routes template and generate * * @param string $path * @param string $name * @param array $options * @return boolean */ public function make($path, $name, array $options = []) { $options += ['filter' => null, 'prefix' => null]; $this->parsedRoutes = $this->getParsedRoutes($options['filter'], $options['prefix']); $template = $this->file->get(__DIR__ . '/templates/Router.js'); $template = str_replace("routes: null,", 'routes: ' . json_encode($this->parsedRoutes) . ',', $template); $template = str_replace("'Router'", "'" . $options['object'] . "'", $template); if ($this->file->isWritable($path)) { $filename = $path . '/' . $name; return $this->file->put($filename, $template) !== false; } return false; }
/** * Set the path for the JSON file. * * @param string $path */ public function setPath($path) { if (!$this->filesystem->exists($path)) { $result = $this->filesystem->put($path, '{}'); if (!$result) { throw new \InvalidArgumentException("Could not write to {$path}."); } } if (!$this->filesystem->isWritable($path)) { throw new \InvalidArgumentException("{$path} is not writable."); } $this->path = $path; }
/** * Set the path for the JSON file. * * @param string $path * @throws NotWritableException */ public function setPath($path) { if (!$this->files->exists($path)) { $result = $this->files->put($path, '{}'); if ($result === false) { throw new NotWritableException("Could not write to {$path}."); } } if (!$this->files->isWritable($path)) { throw new NotWritableException("{$path} is not writable."); } $this->path = $path; }
/** * Perform undo action * * @return void */ protected function undo() { // Delete status $deleteCompleted = true; // Get files from the json undo file $files = json_decode($this->filesystem->get($this->undoFilePath), true); // For each file $this->info('Deleting files:'); foreach ($files as $file) { // If this file can be deleted if ($this->filesystem->isWritable($file)) { // Delete it $this->filesystem->delete($file); $this->info(" Deleted: {$file}"); } else { // Set status $deleteCompleted = false; // Show error $this->error('Could not delete: ' . $file); } } // if the delete prccess finished successfully if ($deleteCompleted) { // Delete undo file $this->filesystem->delete($this->undoFilePath); } }
/** * @param \Exolnet\Image\Imageable $image * @param \Symfony\Component\HttpFoundation\File\File $file * @return bool * @throws \Exolnet\Core\Exceptions\ServiceValidationException */ public function store(Imageable $image, File $file) { if (!$image->getFilename()) { throw new ServiceValidationException('Could not store image with an empty filename.'); } $path = dirname($image->getImagePath()); $filename = basename($image->getImagePath()); if (!$this->filesystem->exists($path)) { $this->filesystem->makeDirectory($path, 0755, true); } if (!$this->filesystem->isWritable($path)) { throw new ServiceValidationException('The image base path "' . $path . '" is not writable.'); } $file->move($path, $filename); return true; }
/** * Handle the command. * * @param Filesystem $files * @param Application $application */ public function handle(Filesystem $files, Application $application) { $paths = ['storage', $application->getStoragePath(), 'public/assets', $application->getAssetsPath()]; foreach ($paths as $path) { if ($files->exists(base_path($path)) && !$files->isWritable(base_path($path))) { die('chmod -R 777 ' . base_path($path)); } } }
/** * Where in the /public directory should the files * be stored? * * @return string $path */ public function getStaticPathLocation() { $path = public_path() . $this->fileLocation; if (!$this->fs->isWritable($path)) { throw new PathNotWritableException(); } if (!$this->fs->isDirectory($path)) { $this->fs->makeDirectory($path); } return $path; }
/** * Erstellt die module.json Datei * * @param string $module * @return void */ private function createFile($module) { $module = $this->modules[$module]; if($this->files->isWritable($module)) { $this->files->copy(__DIR__.'/../templates/module.json', $module.'/module.json'); } else { return App::abort('403', "Please set writable permissions to " . $module . "\n"); } }
protected function checkEnv($path, $name, $namespace, $title) { // check directory exists if ($this->files->exists($path)) { $this->error($this->type . ' already exists!'); return false; } // check permission $pluginsDir = app('xe.plugin')->getPluginsDir(); if (!$this->files->isWritable($pluginsDir)) { $this->error("Permission denied. Can not create plugin directory({$path})."); return false; } }
protected function checkEnv($path, $name, $namespace, $title) { // check directory exists if ($this->files->exists($path)) { $this->error('Plugin already exists!'); return false; } // check namespace if (!str_contains($namespace, '\\')) { $this->error('The namespace must have at least 1 delimiter(\\), use double backslash(\\\\) as delimiter'); return false; } // check permission $pluginsDir = app('xe.plugin')->getPluginsDir(); if (!$this->files->isWritable($pluginsDir)) { $this->error("Permission denied. Can not create plugin directory({$path})."); return false; } }
/** * Determine if the given path is writable. * * @param string $path * @return bool * @static */ public static function isWritable($path) { return \Illuminate\Filesystem\Filesystem::isWritable($path); }
/** * Helper to ensure attachment folder */ protected function ensureAttachmentFolder() { $file = new Filesystem(); // Ensure base folder if (!$file->isDirectory($this->directory)) { $file->makeDirectory($this->directory, 0777, true); } // Ensure media folder if (!$file->isDirectory($this->media_directory)) { $file->makeDirectory($this->media_directory, 0777, true); } if (!$file->isWritable($this->directory) || !$file->isWritable($this->media_directory)) { throw new RuntimeException('Invalid attachment directory'); } }