¿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.

_umask

Sets the default file-permission mask. This function is deprecated because a more secure version is available; see _umask_s.


int _umask(
   int pmode 
);

Parameters

pmode

Default permission setting.

_umask returns the previous value of pmode. There is no error return.

The _umask function sets the file-permission mask of the current process to the mode specified by pmode. The file-permission mask modifies the permission setting of new files created by _creat, _open, or _sopen. If a bit in the mask is 1, the corresponding bit in the file's requested permission value is set to 0 (disallowed). If a bit in the mask is 0, the corresponding bit is left unchanged. The permission setting for a new file is not set until the file is closed for the first time.

The integer expression pmode contains one or both of the following manifest constants, defined in SYS\STAT.H:

_S_IWRITE

Writing permitted.

_S_IREAD

Reading permitted.

_S_IREAD | _S_IWRITE

Reading and writing permitted.

When both constants are given, they are joined with the bitwise-OR operator ( | ). If the pmode argument is _S_IREAD, reading is not allowed (the file is write-only). If the pmode argument is _S_IWRITE, writing is not allowed (the file is read-only). For example, if the write bit is set in the mask, any new files will be read-only. Note that with MS-DOS and the Windows operating systems, all files are readable; it is not possible to give write-only permission. Therefore, setting the read bit with _umask has no effect on the file's modes.

If pmode is not a combination of one of the manifest constants or incorporates an alternate set of constants, the function will simply ignore those.

Routine Required header Compatibility

_umask

<io.h>, <sys/stat.h>, <sys/types.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

For additional compatibility information, see Compatibility in the Introduction.

All versions of the C run-time libraries.

// crt_umask.c
// compile with: /W1
// This program uses _umask to set
// the file-permission mask so that all future
// files will be created as read-only files.
// It also displays the old mask.
#include <sys/stat.h>
#include <sys/types.h>
#include <io.h>
#include <stdio.h>

int main( void )
{
   int oldmask;

   /* Create read-only files: */
   oldmask = _umask( _S_IWRITE ); // C4996
   // Note: _umask is deprecated; consider using _umask_s instead
   printf( "Oldmask = 0x%.4x\n", oldmask );
}

Output

Oldmask = 0x0000

Adiciones de comunidad

AGREGAR
Mostrar:
© 2015 Microsoft