当前位置: 首页>>代码示例>>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;未经允许,请勿转载。