¿Le resultó útil esta página?
Sus comentarios sobre este contenido son muy importantes. Háganos saber su opinión.
¿Tiene comentarios adicionales?
Caracteres restantes: 1500
Exportar (0) Imprimir
Expandir todo
div
eof
Expandir Minimizar
Importante Es posible que este documento no represente los procedimientos recomendados para el desarrollo actual. Puede que los vínculos a las descargas y otros recursos ya no sean válidos. Encontrará aquí la versión que se recomienda en la actualidad.

_splitpath_s, _wsplitpath_s

Break a path name into components. These are versions of _splitpath, _wsplitpath with security enhancements as described in Security Enhancements in the CRT.


errno_t _splitpath_s(
   const char * path,
   char * drive,
   size_t driveSizeInCharacters,
   char * dir,
   size_t dirSizeInCharacters,
   char * fname,
   size_t nameSizeInCharacters,
   char * ext, 
   size_t extSizeInBytes
);
errno_t _wsplitpath_s(
   const wchar_t * path,
   wchar_t * drive,
   size_t driveSizeInCharacters,
   wchar_t *dir,
   size_t dirSizeInCharacters,
   wchar_t * fname,
   size_t nameSizeInCharacters,
   wchar_t * ext,
   size_t extSizeInCharacters
);
template <size_t drivesize, size_t dirsize, size_t fnamesize, size_t extsize>
errno_t _splitpath_s(
   const char *path,
   char (&drive)[drivesize],
   char (&dir)[dirsize],
   char (&fname)[fnamesize],
   char (&ext)[extsize]
); // C++ only
template <size_t drivesize, size_t dirsize, size_t fnamesize, size_t extsize>
errno_t _wsplitpath_s(
   const wchar_t *path,
   wchar_t (&drive)[size],
   wchar_t (&dir)[size],
   wchar_t (&fname)[size],
   wchar_t (&ext)[size]
); // C++ only

Parameters

[in] path

Full path

[out] drive

Optional drive letter, followed by a colon (:)

[in] driveSizeInCharacters

The size of the drive buffer in single-byte or wide characters.

[out] dir

Optional directory path, including trailing slash. Forward slashes ( / ), backslashes ( \ ), or both may be used.

[in] dirSizeInCharacters

The size of the dir buffer in single-byte or wide characters.

[out] fname

Base filename (no extension)

[in] nameSizeInCharacters

The size of the fname buffer in single-byte or wide characters.

[out] ext

Optional filename extension, including leading period (.)

[in] extSizeInCharacters

The size of ext buffer in single-byte or wide characters.

Zero if successful; an error code on failure.

Error Conditions
Condition Return Value

path is NULL

EINVAL

drive is NULL, driveSizeinCharacters is non-zero

EINVAL

drive is non-NULL, driveSizeInCharacters is zero

EINVAL

dir is NULL, dirSizeinCharacters is non-zero

EINVAL

dir is non-NULL, dirSizeInCharacters is zero

EINVAL

fname is NULL, nameSizeinCharacters is non-zero

EINVAL

fname is non-NULL, nameSizeInCharacters is zero

EINVAL

ext is NULL, extSizeinCharacters is non-zero

EINVAL

ext is non-NULL, extSizeInCharacters is zero

EINVAL

If any of the above conditions occurs, the invalid parameter handler is invoked, as described in Parameter Validation . If execution is allowed to continue, these functions set errno to EINVAL and return EINVAL.

If any of the buffers is too short to hold the result, these functions clear all the buffers to empty strings, set errno to ERANGE, and return ERANGE.

The _splitpath_s function breaks a path into its four components. _splitpath_s automatically handles multibyte-character string arguments as appropriate, recognizing multibyte-character sequences according to the multibyte code page currently in use. _wsplitpath_s is a wide-character version of _splitpath_s; the arguments to _wsplitpath_s are wide-character strings. These functions behave identically otherwise

Generic-Text Routine Mappings
TCHAR.H routine _UNICODE & _MBCS not defined _MBCS defined _UNICODE defined

_tsplitpath

_splitpath

_splitpath

_wsplitpath

Each argument is stored in a buffer; the manifest constants _MAX_DRIVE, _MAX_DIR, _MAX_FNAME, and _MAX_EXT (defined in STDLIB.H) specify the maximum size necessary for each buffer. The other arguments point to buffers used to store the path elements. After a call to _splitpath_s is executed, these arguments contain empty strings for components not found in path. You can pass a NULL pointer to _splitpath_s for any component you don't need.

In C++, using these functions is simplified by template overloads; the overloads can infer buffer length automatically, eliminating the need to specify a size argument. For more information, see Secure Template Overloads.

Routine Required header Compatibility

_splitpath_s

<stdlib.h>

Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003

_wsplitpath_s

<stdlib.h> or <wchar.h>

Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003

For additional compatibility information, see Compatibility in the Introduction.

See the example for _makepath_s, _wmakepath_s.

Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.

Adiciones de comunidad

AGREGAR
Mostrar:
© 2015 Microsoft