选择语言 :

 Core_File::create_dir

循环建立目录,多服务器可以自动同步

boolean Core_File::create_dir( string $dir [, boolean $auto_create_default_file = bool true , string $storage = string(7) "default" ] )

参数列表

参数 类型 描述 默认值
$dir string 待创建的文件夹
$auto_create_default_file boolean 新创建的文件夹,是否自动创建空默认页 bool true
$storage string 物理存储组,不传则为默认 string(7) "default"
返回值
  • boolean true/false
File: ./core/classes/file.class.php
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
public static function create_dir($dir, $auto_create_default_file = true , $storage = 'default')
{
    $info = File::check_and_get_path($dir);
 
    if (File::can_do_run($storage))
    {
        if (!is_dir($dir))
        {
            if ( substr($dir,0,strlen(DIR_SYSTEM))==DIR_SYSTEM )
            {
                $temp = explode('/', str_replace('\\', '/', substr($dir,strlen(DIR_SYSTEM)) ) );
                $cur_dir = DIR_SYSTEM;
            }
            else
            {
                $temp = explode('/', str_replace('\\', '/', $dir) );
                $cur_dir = '';
            }
            for($i = 0; $i < count($temp); $i++)
            {
                $cur_dir .= $temp[$i] . '/';
                if (!@is_dir($cur_dir))
                {
                    if (@mkdir($cur_dir, 0755))
                    {
                        if ($auto_create_default_file)File::create_file($cur_dir.'index.html', ' ');
                    }
                    else
                    {
                        return false;
                    }
                }
            }
        }
 
        return true;
    }
    else
    {
        return File::call_http_host($storage, 'file/create_dir', $info[0], $info[1], $auto_create_default_file);
    }
}