本文整理汇总了PHP中Varien_Io_File::dirsep方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Io_File::dirsep方法的具体用法?PHP Varien_Io_File::dirsep怎么用?PHP Varien_Io_File::dirsep使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Io_File
的用法示例。
在下文中一共展示了Varien_Io_File::dirsep方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: moveFileFromTmp
/**
* Move file from tmp path to base path
*
* @param string $baseTmpPath
* @param string $basePath
* @param string $file
* @return string
*/
public function moveFileFromTmp($baseTmpPath, $basePath, $file)
{
$ioObject = new Varien_Io_File();
$destDirectory = dirname($this->getFilePath($basePath, $file));
try {
$ioObject->open(array('path' => $destDirectory));
} catch (Exception $e) {
$ioObject->mkdir($destDirectory, 0777, true);
$ioObject->open(array('path' => $destDirectory));
}
if (strrpos($file, '.tmp') == strlen($file) - 4) {
$file = substr($file, 0, strlen($file) - 4);
}
$destFile = dirname($file) . $ioObject->dirsep() . Varien_File_Uploader::getNewFileName($this->getFilePath($basePath, $file));
$result = $ioObject->mv($this->getFilePath($baseTmpPath, $file), $this->getFilePath($basePath, $file));
return str_replace($ioObject->dirsep(), '/', $destFile);
}
示例2: _copyImage
protected function _copyImage($file)
{
try {
$ioObject = new Varien_Io_File();
$destDirectory = dirname($this->_getConfig()->getMediaPath($file));
$ioObject->open(array('path' => $destDirectory));
$destFile = $this->_getUniqueFileName($file, $ioObject->dirsep());
if (!$ioObject->fileExists($this->_getConfig()->getMediaPath($file), true)) {
throw new Exception('File not exists');
}
if ($this->_checkDb()) {
Mage::helper('core/file_storage_database')->copyFile($this->_getConfig()->getMediaShortUrl($file), $this->_getConfig()->getMediaShortUrl($destFile));
$ioObject->rm($this->_getConfig()->getMediaPath($destFile));
} else {
$ioObject->cp($this->_getConfig()->getMediaPath($file), $this->_getConfig()->getMediaPath($destFile));
}
} catch (Exception $e) {
$file = $this->_getConfig()->getMediaPath($file);
Mage::throwException(Mage::helper('ampaction')->__('Failed to copy file %s. Please, delete media with non-existing images and try again.', $file));
$e = $e;
// for zend debugger
}
return str_replace($ioObject->dirsep(), '/', $destFile);
}
示例3: _moveFileFromTmp
protected function _moveFileFromTmp($baseTmpPath, $basePath, $file)
{
$ioObject = new Varien_Io_File();
$destDirectory = dirname($this->getFilePath($basePath, $file));
try {
$ioObject->open(array('path' => $destDirectory));
} catch (Exception $e) {
$ioObject->mkdir($destDirectory, 0777, true);
$ioObject->open(array('path' => $destDirectory));
}
if (strrpos($file, '.tmp') == strlen($file) - 4) {
$file = substr($file, 0, strlen($file) - 4);
}
// DO NOT rename file if it exists. Overwrite it. Custumer request in ticket#2012120510000418 — Magento is losing connection to files
$destFile = $file;
//$destFile = dirname($file) . $ioObject->dirsep()
// . Mage_Core_Model_File_Uploader::getNewFileName($this->getFilePath($basePath, $file));
//die ("destFile: $destFile<br>file: $file<br>basePath: $basePath<br>dirname: ".dirname($file));
Mage::helper('core/file_storage_database')->copyFile($this->getFilePath($baseTmpPath, $file), $this->getFilePath($basePath, $destFile));
$result = $ioObject->mv($this->getFilePath($baseTmpPath, $file), $this->getFilePath($basePath, $destFile));
return str_replace($ioObject->dirsep(), '/', $destFile);
}
示例4: _moveFileFromTmp
/**
* Move file from tmp path to base path
*
* @param string $baseTmpPath
* @param string $basePath
* @param string $file
* @return string
*/
protected function _moveFileFromTmp($baseTmpPath, $basePath, $file)
{
$ioObject = new Varien_Io_File();
$destDirectory = dirname($this->getFilePath($basePath, $file));
try {
$ioObject->open(array('path' => $destDirectory));
} catch (Exception $e) {
$ioObject->mkdir($destDirectory, 0777, true);
$ioObject->open(array('path' => $destDirectory));
}
if (strrpos($file, '.tmp') == strlen($file) - 4) {
$file = substr($file, 0, strlen($file) - 4);
}
$destFile = dirname($file) . $ioObject->dirsep() . Mage_Core_Model_File_Uploader::getNewFileName($this->getFilePath($basePath, $file));
Mage::helper('Mage_Core_Helper_File_Storage_Database')->copyFile($this->getFilePath($baseTmpPath, $file), $this->getFilePath($basePath, $destFile));
$result = $ioObject->mv($this->getFilePath($baseTmpPath, $file), $this->getFilePath($basePath, $destFile));
return str_replace($ioObject->dirsep(), '/', $destFile);
}
示例5: _copyImage
/**
* Copy image and return new filename.
*
* @param string $file
* @return string
*/
protected function _copyImage($file)
{
try {
$ioObject = new Varien_Io_File();
$destDirectory = dirname($this->_getConfig()->getMediaPath($file));
$ioObject->open(array('path' => $destDirectory));
$destFile = dirname($file) . $ioObject->dirsep() . Varien_File_Uploader::getNewFileName($this->_getConfig()->getMediaPath($file));
if (!$ioObject->fileExists($this->_getConfig()->getMediaPath($file), true)) {
throw new Exception();
}
$ioObject->cp($this->_getConfig()->getMediaPath($file), $this->_getConfig()->getMediaPath($destFile));
} catch (Exception $e) {
Mage::throwException(Mage::helper('catalog')->__('Failed to copy file %s. Please, delete media with non-existing images and try again.', $this->_getConfig()->getMediaPath($file)));
}
return str_replace($ioObject->dirsep(), '/', $destFile);
}
示例6: _moveImageFromTmp
/**
* Move image from temporary directory to normal
*
* @param string $file
* @return string
*/
protected function _moveImageFromTmp($file)
{
$ioObject = new Varien_Io_File();
$destDirectory = dirname($this->_getConfig()->getMediaPath($file));
try {
$ioObject->open(array('path' => $destDirectory));
} catch (Exception $e) {
$ioObject->mkdir($destDirectory, 0777, true);
$ioObject->open(array('path' => $destDirectory));
}
$destFile = dirname($file) . $ioObject->dirsep() . Varien_File_Uploader::getNewFileName($this->_getConfig()->getMediaPath($file));
$ioObject->mv($this->_getConfig()->getTmpMediaPath($file), $this->_getConfig()->getMediaPath($destFile));
return $destFile;
}
示例7: copyImage
/**
* Copy image from temp folder
*
* @param array $image
* @return string
*/
public function copyImage($image)
{
$ioObject = new Varien_Io_File();
$file = $image['file'];
$destDirectory = dirname($this->_getConfig()->getMediaPath($file));
try {
$ioObject->open(array('path' => $destDirectory));
} catch (Exception $e) {
$ioObject->mkdir($destDirectory, 0777, true);
$ioObject->open(array('path' => $destDirectory));
}
if (strrpos($file, '.tmp') == strlen($file) - 4) {
$file = substr($file, 0, strlen($file) - 4);
}
$destFile = $this->_getUniqueFileName($file, $ioObject->dirsep());
/** @var $storageHelper Mage_Core_Helper_File_Storage_Database */
$storageHelper = Mage::helper('core/file_storage_database');
if ($storageHelper->checkDbUsage()) {
$storageHelper->renameFile($this->_getConfig()->getTmpMediaShortUrl($file), $this->_getConfig()->getMediaShortUrl($destFile));
$ioObject->rm($this->_getConfig()->getTmpMediaPath($file));
$ioObject->rm($this->_getConfig()->getMediaPath($destFile));
} else {
$ioObject->mv($this->_getConfig()->getTmpMediaPath($file), $this->_getConfig()->getMediaPath($destFile));
}
return str_replace($ioObject->dirsep(), '/', $destFile);
}
示例8: _copyImage
/**
* Copy image and return new filename.
*
* @param string $file
* @return string
*/
protected function _copyImage($file)
{
$ioObject = new Varien_Io_File();
$destDirectory = dirname($this->_getConfig()->getMediaPath($file));
$ioObject->open(array('path' => $destDirectory));
$destFile = dirname($file) . $ioObject->dirsep() . Varien_File_Uploader::getNewFileName($this->_getConfig()->getMediaPath($file));
$ioObject->cp($this->_getConfig()->getMediaPath($file), $this->_getConfig()->getMediaPath($destFile));
return str_replace($ioObject->dirsep(), '/', $destFile);
}