當前位置: 首頁>>代碼示例>>PHP>>正文


PHP File::exists方法代碼示例

本文整理匯總了PHP中File::exists方法的典型用法代碼示例。如果您正苦於以下問題:PHP File::exists方法的具體用法?PHP File::exists怎麽用?PHP File::exists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在File的用法示例。


在下文中一共展示了File::exists方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['file' => 'required']);
     $file = $request->file('file');
     $original_file_name = $file->getClientOriginalName();
     $file_name = pathinfo($original_file_name, PATHINFO_FILENAME);
     $extension = \File::extension($original_file_name);
     $actual_name = $file_name . '.' . $extension;
     $apk = new \ApkParser\Parser($file);
     $manifest = $apk->getManifest();
     $labelResourceId = $apk->getManifest()->getApplication()->getLabel();
     $appLabel = $apk->getResources($labelResourceId);
     $package_name = $manifest->getPackageName();
     if (Apk::packageExist($package_name)) {
         Session::flash('flash_class', 'alert-danger');
         Session::flash('flash_message', 'Apk namespace already exist.');
         return redirect()->route("apk.create");
     }
     Apk::create(array('app_name' => $appLabel[0], 'pkgname' => $package_name, 'version' => $manifest->getVersionCode(), 'version_name' => $manifest->getVersionName(), 'md5' => md5_file($file), 'filename' => $actual_name, 'filesize' => str_format_filesize(\File::size($file)), 'token' => md5(uniqid(mt_rand(), true))));
     $folderpath = base_path() . '/storage/apk/' . $manifest->getPackageName();
     if (!\File::exists($folderpath)) {
         \File::makeDirectory($folderpath);
     }
     $file_path = $request->file('file')->move($folderpath, $actual_name);
     return redirect()->route("apk.index");
 }
開發者ID:renciebautista,項目名稱:pcount2,代碼行數:32,代碼來源:ApkController.php

示例2: copy

 public function copy($destination, $overwrite = false, $mt = false)
 {
     //    if (dirname($destination) == ".") {
     //      $destination = $this->getDirectory() . DS . $destination;
     //    }
     $destination = $this->preparePath($destination);
     if (strcmp(substr($destination, -1), DS) == 0) {
         $destination .= $this->getName();
     }
     $file = new File($destination);
     $dir = new Directory($file->getDirectory());
     if (!$dir->exists() && !$dir->make()) {
         throw new FileException(array("Directory '%s' not exists.", $dir->getPath()));
     }
     if (!$overwrite && $file->exists()) {
         throw new FileException(array("File '%s' already exists.", $file->getPath()));
     }
     if ($file->exists() && !$file->delete()) {
         throw new FileException(array("File '%s' cannot be deleted.", $file->getPath()));
     }
     if (!copy($this->pathAbsolute, $file->getPathAbsolute())) {
         throw new FileException(array("Failed to copy file '%s'.", $this->path));
     }
     if ($mt) {
         $filemtime = $this->getModificationTime();
         @touch($file->getPathAbsolute(), $filemtime);
     }
     return $file;
 }
開發者ID:rolandrajko,項目名稱:BREAD,代碼行數:29,代碼來源:File.php

示例3: build

 public function build()
 {
     $this->file = wfLocalFile($this->title);
     if ($this->file && $this->file->exists()) {
         $this->fileText();
     }
     return $this->doc;
 }
開發者ID:zoglun,項目名稱:mediawiki-extensions-CirrusSearch,代碼行數:8,代碼來源:FileDataBuilder.php

示例4: testSystemCall

 function testSystemCall()
 {
     $command = "touch " . SITE_ROOT_PATH . "/tmp/prova.txt";
     system($command);
     $f = new File("/tmp/prova.txt");
     $this->assertTrue($f->exists(), "Il file non e' stato creato!!");
     if ($f->exists()) {
         $f->delete();
     }
 }
開發者ID:mbcraft,項目名稱:frozen,代碼行數:10,代碼來源:system_test.php

示例5: get

 /**
  * Returns the content of the array in the file.
  *
  * If no array with the specified name exists, an empty array will be returned.
  *
  * @return array Array read from the file.
  */
 function get()
 {
     if ($this->file->exists() == true) {
         @(include $this->file->relPath());
     }
     if (isset(${$this->varname}) == false) {
         ${$this->varname} = array();
     }
     return ${$this->varname};
 }
開發者ID:BackupTheBerlios,項目名稱:viscacha-svn,代碼行數:17,代碼來源:class.FileArray.php

示例6: testBlackHole

 function testBlackHole()
 {
     $f = new File("/" . FRAMEWORK_CORE_PATH . "tests/io/black_hole_test.php");
     $this->assertTrue($f->exists(), "Il file del test non esiste!!");
     $content = $f->getContent();
     $f->delete();
     $this->assertFalse($f->exists(), "Il file del test black hole non e' stato eliminato!!");
     $f->touch();
     $f->setContent($content);
     $this->assertTrue($f->exists(), "Il file del test black hole non e' stato rigenerato!!");
 }
開發者ID:mbcraft,項目名稱:frozen,代碼行數:11,代碼來源:black_hole_test.php

示例7: parse

 public function parse()
 {
     $this->setTimeOut();
     $this->cacheFile = new \File($this->cacheFilePath, true);
     if (!$this->cacheFile->exists()) {
         return;
     }
     $this->getCacheFromFile();
     if (empty($this->cacheUrl)) {
         return;
     }
     $this->buildCache();
 }
開發者ID:contaoblackforest,項目名稱:contao-cron-cache-pages,代碼行數:13,代碼來源:Builder.php

示例8: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $path = $this->getFilePath();
     $directory = dirname($path);
     if ($this->file->exists($path)) {
         $this->error("A view already exists at {$path}!");
         return false;
     }
     if (!$this->file->exists($directory)) {
         $this->file->makeDirectory($directory, 0777, true);
     }
     $this->file->put($path, $this->getViewContents());
     $this->info("Created a new view at {$path}");
 }
開發者ID:maddhatter,項目名稱:laravel-view-generator,代碼行數:19,代碼來源:MakeViewCommand.php

示例9: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\File::exists(base_path() . '/config/invoicer.php')) {
         return $next($request);
     }
     return redirect('install');
 }
開發者ID:edouardkombo,項目名稱:spinv,代碼行數:14,代碼來源:Install.php

示例10: update

 /**
  * Update the specified powerful in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $powerful = Powerful::findOrFail($id);
     $rules = array('name' => 'required', 'icon' => 'image');
     $validator = Validator::make($data = Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     //upload powerful icon
     if (Input::hasFile('icon')) {
         //delete old icon
         if (File::exists($powerful->icon)) {
             File::delete($powerful->icon);
         }
         //create new icon
         $name = md5(time() . Input::file('icon')->getClientOriginalName()) . '.' . Input::file('icon')->getClientOriginalExtension();
         $folder = "public/uploads/powerful";
         Input::file('icon')->move($folder, $name);
         $path = $folder . '/' . $name;
         //update new path
         $data['icon'] = $path;
     } else {
         unset($data['icon']);
     }
     $powerful->update($data);
     return Redirect::route('admin.powerful.index')->with('message', 'Item had updated!');
 }
開發者ID:vnzacky,項目名稱:exp_services,代碼行數:33,代碼來源:PowerfulController.php

示例11: postDelete

 /**
  * Remove the specified company from storage.
  *
  * @param $company
  * @return Response
  */
 public function postDelete($model)
 {
     // Declare the rules for the form validation
     $rules = array('id' => 'required|integer');
     // Validate the inputs
     $validator = Validator::make(Input::All(), $rules);
     // Check if the form validates with success
     if ($validator->passes()) {
         $id = $model->id;
         $model->delete();
         $file_path = public_path() . '/uploads/' . $model->filename;
         $file_ok = true;
         if (File::exists($file_path)) {
             $file_ok = false;
             File::delete($file_path);
             if (!File::exists($file_path)) {
                 $file_ok = true;
             }
         }
         // Was the blog post deleted?
         $Model = $this->modelName;
         $model = $Model::find($id);
         if (empty($model) && $file_ok) {
             // Redirect to the blog posts management page
             return Response::json(['success' => 'success', 'reload' => true]);
         }
     }
     // There was a problem deleting the blog post
     return Response::json(['error' => 'error', 'reload' => false]);
 }
開發者ID:strikles,項目名稱:php,代碼行數:36,代碼來源:PicturesController.php

示例12: renderContent

 /**
  * Render a single message content element.
  *
  * @param RenderMessageContentEvent $event
  *
  * @return string
  */
 public function renderContent(RenderMessageContentEvent $event)
 {
     global $container;
     $content = $event->getMessageContent();
     if ($content->getType() != 'downloads' || $event->getRenderedContent()) {
         return;
     }
     /** @var EntityAccessor $entityAccessor */
     $entityAccessor = $container['doctrine.orm.entityAccessor'];
     $context = $entityAccessor->getProperties($content);
     $context['files'] = array();
     foreach ($context['downloadSources'] as $index => $downloadSource) {
         $context['downloadSources'][$index] = $downloadSource = \Compat::resolveFile($downloadSource);
         $file = new \File($downloadSource, true);
         if (!$file->exists()) {
             unset($context['downloadSources'][$index]);
             continue;
         }
         $context['files'][$index] = array('url' => $downloadSource, 'size' => \System::getReadableSize(filesize(TL_ROOT . DIRECTORY_SEPARATOR . $downloadSource)), 'icon' => 'assets/contao/images/' . $file->icon, 'title' => basename($downloadSource));
     }
     if (empty($context['files'])) {
         return;
     }
     $template = new \TwigTemplate('avisota/message/renderer/default/mce_downloads', 'html');
     $buffer = $template->parse($context);
     $event->setRenderedContent($buffer);
 }
開發者ID:avisota,項目名稱:contao-message-element-downloads,代碼行數:34,代碼來源:DefaultRenderer.php

示例13: read

 /**
  * Read a key from the cache
  *
  * @param string $key Identifier for the data
  * @return mixed The cached data, or false if the data doesn't exist, has expired, or if there was an error fetching it
  * @access public
  */
 function read($key)
 {
     // Modifications by webligo
     $key .= '.php';
     // end modifications
     if ($this->__setKey($key) === false || !$this->__init || !$this->__File->exists()) {
         return false;
     }
     if ($this->settings['lock']) {
         $this->__File->lock = true;
     }
     // Modifications by webligo
     $this->__File->open('rb');
     fgets($this->__File->handle);
     // Strip off die
     $key .= '.php';
     // end modifications
     $time = time();
     $cachetime = intval($this->__File->read(11));
     if ($cachetime !== false && ($cachetime < $time || $time + $this->settings['duration'] < $cachetime)) {
         $this->__File->close();
         return false;
     }
     $data = $this->__File->read(true);
     if ($data !== '' && !empty($this->settings['serialize'])) {
         if ($this->settings['isWindows']) {
             $data = str_replace('\\\\\\\\', '\\', $data);
         }
         $data = unserialize((string) $data);
     }
     $this->__File->close();
     return $data;
 }
開發者ID:Maharaja1,項目名稱:thebest-social,代碼行數:40,代碼來源:file.php

示例14: read

 /**
  * Read a key from the cache
  *
  * @param string $key Identifier for the data
  * @return mixed The cached data, or false if the data doesn't exist, has expired, or if there was an error fetching it
  * @access public
  */
 function read($key)
 {
     if ($this->__setKey($key) === false || !$this->__init || !$this->__File->exists()) {
         return false;
     }
     if ($this->settings['lock']) {
         $this->__File->lock = true;
     }
     $time = time();
     $cachetime = intval($this->__File->read(11));
     if ($cachetime !== false && ($cachetime < $time || $time + $this->settings['duration'] < $cachetime)) {
         $this->__File->close();
         $this->__File->delete();
         return false;
     }
     $data = $this->__File->read(true);
     if ($data !== '' && !empty($this->settings['serialize'])) {
         if ($this->settings['isWindows']) {
             $data = str_replace('\\\\\\\\', '\\', $data);
         }
         $data = unserialize((string) $data);
     }
     $this->__File->close();
     return $data;
 }
開發者ID:jerzzz777,項目名稱:cake-cart,代碼行數:32,代碼來源:file.php

示例15: parseFile

 /**
  * Specifically parses a file
  *
  * @param string  $file  YAML-formatted File to parse
  * @return array
  */
 public static function parseFile($file)
 {
     if (File::exists($file)) {
         return self::parse($file);
     }
     return array();
 }
開發者ID:nob,項目名稱:joi,代碼行數:13,代碼來源:yaml.php


注:本文中的File::exists方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。