_mkdir、_wmkdir_mkdir, _wmkdir
新しいディレクトリを作成します。Creates a new directory.
構文Syntax
int _mkdir(
const char *dirname
);
int _wmkdir(
const wchar_t *dirname
);
パラメーターParameters
dirnamedirname
新しいディレクトリのパス。Path for a new directory.
戻り値Return Value
新しいディレクトリが作成された場合、これらの各関数は値 0 を返します。Each of these functions returns the value 0 if the new directory was created. エラーが発生した場合、この関数は-1 を返し、 errno を次のように設定します。On an error, the function returns -1 and sets errno as follows.
*Eexist***Dirname が既存のファイル、ディレクトリ、またはデバイスの名前であるため、ディレクトリは作成されませんでした。EEXIST Directory was not created because dirname is the name of an existing file, directory, or device.
ENOENT パスが見つかりませんでした。ENOENT Path was not found.
リターン コードの詳細については、「_doserrno、errno、_sys_errlist、および _sys_nerr」を参照してください。For more information about these and other return codes, see _doserrno, errno, _sys_errlist, and _sys_nerr.
解説Remarks
_Mkdir 関数は、指定された dirname を持つ新しいディレクトリを作成し ます。The _mkdir function creates a new directory with the specified dirname. _mkdir は呼び出しごとに1つの新しいディレクトリを作成できます。そのため、 dirname の最後のコンポーネントのみが新しいディレクトリに名前を指定できます。_mkdir can create only one new directory per call, so only the last component of dirname can name a new directory. _mkdir はパス区切り記号を変換しません。_mkdir does not translate path delimiters. Windows NT では、バックスラッシュ (\) とスラッシュ (/) のどちらもランタイム ルーチンの文字列内の有効なパス区切り記号です。In Windows NT, both the backslash ( \) and the forward slash (/ ) are valid path delimiters in character strings in run-time routines.
_wmkdir は _mkdir のワイド文字バージョンです。_wmkdir の dirname 引数は、ワイド文字列です。_wmkdir is a wide-character version of _mkdir; the dirname argument to _wmkdir is a wide-character string. _wmkdir と _mkdir は同じように動作します。_wmkdir and _mkdir behave identically otherwise.
既定では、この関数のグローバル状態はアプリケーションにスコープが設定されています。By default, this function's global state is scoped to the application. これを変更するには、「 CRT でのグローバル状態」を参照してください。To change this, see Global state in the CRT.
汎用テキスト ルーチンのマップGeneric-Text Routine Mappings
Tchar.h のルーチンTchar.h routine | _UNICODE および _MBCS が未定義の場合_UNICODE and _MBCS not defined | _MBCS が定義されている場合_MBCS defined | _UNICODE が定義されている場合_UNICODE defined |
---|---|---|---|
_tmkdir_tmkdir | _mkdir_mkdir | _mkdir_mkdir | _wmkdir_wmkdir |
必要条件Requirements
ルーチンによって返される値Routine | 必須ヘッダーRequired header |
---|---|
_mkdir_mkdir | <direct.h> |
_wmkdir_wmkdir | <direct.h> または <wchar.h><direct.h> or <wchar.h> |
互換性について詳しくは、「 Compatibility」をご覧ください。For more compatibility information, see Compatibility.
ライブラリLibraries
C ランタイム ライブラリのすべてのバージョン。All versions of the C run-time libraries.
例Example
// crt_makedir.c
#include <direct.h>
#include <stdlib.h>
#include <stdio.h>
int main( void )
{
if( _mkdir( "\\testtmp" ) == 0 )
{
printf( "Directory '\\testtmp' was successfully created\n" );
system( "dir \\testtmp" );
if( _rmdir( "\\testtmp" ) == 0 )
printf( "Directory '\\testtmp' was successfully removed\n" );
else
printf( "Problem removing directory '\\testtmp'\n" );
}
else
printf( "Problem creating directory '\\testtmp'\n" );
}
出力例Sample Output
Directory '\testtmp' was successfully created
Volume in drive C has no label.
Volume Serial Number is E078-087A
Directory of C:\testtmp
02/12/2002 09:56a <DIR> .
02/12/2002 09:56a <DIR> ..
0 File(s) 0 bytes
2 Dir(s) 15,498,690,560 bytes free
Directory '\testtmp' was successfully removed
関連項目See also
ディレクトリコントロールDirectory Control
_chdir、_wchdir_chdir, _wchdir
_rmdir、_wrmdir_rmdir, _wrmdir