当前位置: 首页>>代码示例>>PHP>>正文


PHP COM::FileExists方法代码示例

本文整理汇总了PHP中COM::FileExists方法的典型用法代码示例。如果您正苦于以下问题:PHP COM::FileExists方法的具体用法?PHP COM::FileExists怎么用?PHP COM::FileExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在COM的用法示例。


在下文中一共展示了COM::FileExists方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: relocateShortcut

 private static function relocateShortcut()
 {
     $WshShell = new COM('WScript.Shell', null, CP_UTF8);
     $FSO = new COM('Scripting.FileSystemObject', null, CP_UTF8);
     $desktop = $WshShell->SpecialFolders('Desktop');
     $startmenu = $WshShell->SpecialFolders('Programs');
     $startmenu = $FSO->BuildPath($startmenu, utf8_encode('XAMPP for Windows'));
     $xampppath = utf8_encode(self::$xampppath);
     $links = array();
     $links[$FSO->BuildPath($desktop, utf8_encode('XAMPP Control Panel.lnk'))] = array('TargetPath' => $FSO->BuildPath($xampppath, utf8_encode('xampp-control.exe')), 'WorkingDirectory' => $xampppath, 'WindowStyle' => 1, 'IconLocation' => $FSO->BuildPath($xampppath, utf8_encode('xampp-control.exe')), 'Description' => utf8_encode('XAMPP Control Panel'));
     $links[$FSO->BuildPath($startmenu, utf8_encode('XAMPP Control Panel.lnk'))] = array('TargetPath' => $FSO->BuildPath($xampppath, utf8_encode('xampp-control.exe')), 'WorkingDirectory' => $xampppath, 'WindowStyle' => 1, 'IconLocation' => $FSO->BuildPath($xampppath, utf8_encode('xampp-control.exe')), 'Description' => utf8_encode('XAMPP Control Panel'));
     $links[$FSO->BuildPath($startmenu, utf8_encode('XAMPP Setup.lnk'))] = array('TargetPath' => $FSO->BuildPath($xampppath, utf8_encode('xampp_setup.bat')), 'WorkingDirectory' => $xampppath, 'WindowStyle' => 1, 'IconLocation' => $FSO->BuildPath($xampppath, utf8_encode('xampp_cli.exe')), 'Description' => utf8_encode('XAMPP Setup'));
     $links[$FSO->BuildPath($startmenu, utf8_encode('XAMPP Shell.lnk'))] = array('TargetPath' => $FSO->BuildPath($xampppath, utf8_encode('xampp_shell.bat')), 'WorkingDirectory' => $xampppath, 'WindowStyle' => 1, 'IconLocation' => $FSO->BuildPath($xampppath, utf8_encode('xampp_cli.exe')), 'Description' => utf8_encode('XAMPP Shell'));
     $links[$FSO->BuildPath($startmenu, utf8_encode('XAMPP Uninstall.lnk'))] = array('TargetPath' => $FSO->BuildPath($xampppath, utf8_encode('uninstall_xampp.bat')), 'WorkingDirectory' => $xampppath, 'WindowStyle' => 1, 'IconLocation' => $FSO->BuildPath($xampppath, utf8_encode('xampp_cli.exe')), 'Description' => utf8_encode('XAMPP Uninstall'));
     foreach ($links as $shortcut => $value) {
         if (!$FSO->FileExists($shortcut)) {
             continue;
         }
         try {
             $shortcut_file = $FSO->GetFile($shortcut);
             $oldfileperm = $shortcut_file->attributes;
             if (($oldfileperm & 1) == 1) {
                 $shortcut_file->attributes += -1;
             }
         } catch (Exception $e) {
             throw new XAMPPException('File \'' . utf8_decode($shortcut) . '\' is not writable.');
         }
         $ShellLink = $WshShell->CreateShortcut($shortcut);
         $ShellLink->TargetPath = $value['TargetPath'];
         $ShellLink->WorkingDirectory = $value['WorkingDirectory'];
         $ShellLink->WindowStyle = $value['WindowStyle'];
         $ShellLink->IconLocation = $value['IconLocation'];
         $ShellLink->Description = $value['Description'];
         $ShellLink->Save();
         $ShellLink = null;
         $shortcut_file->attributes = $oldfileperm;
         $shortcut_file = null;
     }
     $FSO = null;
     $WshShell = null;
     return;
 }
开发者ID:join1603,项目名称:wme2a,代码行数:42,代码来源:package__xampp.php

示例2: getArtName

/**
 * Scan the location of the song to find valid cover art file
 * COM object must be used for unicode filenames
 *
 * @param string $path Absolute path of song location
 * @return string Absolute path of cover art file
 */
function getArtName(string $path) : string
{
    $art = "";
    //	Normalize $path
    if (substr($path, 0, -1) != DIRECTORY_SEPARATOR) {
        $path .= DIRECTORY_SEPARATOR;
    }
    //	Art files to search for
    $artNames = array("Folder", "Cover", "folder", "cover");
    $artExtensions = array(".jpg", ".png");
    try {
        $com = new COM("Scripting.FileSystemObject", null, CP_UTF8);
        //	Permute over art filenames
        foreach ($artNames as $name) {
            foreach ($artExtensions as $extension) {
                if ($com->FileExists($path . $name . $extension)) {
                    $art = $path . $name . $extension;
                    break;
                }
            }
        }
    } catch (Exception $e) {
        echo "Unable to search for art: " . $e->getMessage() . "\n";
    }
    $com = null;
    return $art;
}
开发者ID:Serpentsounds,项目名称:Soredemo-Radio,代码行数:34,代码来源:NPUpdater.php


注:本文中的COM::FileExists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。