本文整理汇总了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");
}
示例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;
}
示例3: build
public function build()
{
$this->file = wfLocalFile($this->title);
if ($this->file && $this->file->exists()) {
$this->fileText();
}
return $this->doc;
}
示例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();
}
}
示例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};
}
示例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!!");
}
示例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();
}
示例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}");
}
示例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');
}
示例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!');
}
示例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]);
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}