std::basic_filebuf::open
De cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
<metanoindex/>
<tbody> </tbody> std::basic_filebuf<CharT, Traits>* open( const char* s, std::ios_base::openmode mode ) |
(1) | |
std::basic_filebuf<CharT, Traits>* open( const std::string& s, std::ios_base::openmode mode ) |
(2) | (desde C++11) |
Abre o arquivo cujo nome é dado por
Original:
Opens the file whose name is given by
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
1)
terminada em nulo
s corda estreita byteOriginal:
the null-terminated narrow byte string
sThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
2)
terminada em nulo
s.c_str() corda estreita byteOriginal:
the null-terminated narrow byte string
s.c_str()The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
como se ligando
std::fopen(s, modestring), onde modestring é determinada como se segue:Original:
as if by calling
std::fopen(s, modestring), where modestring is determined as follows:The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
modestring
Original: modestring The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
openmode & ~ate |
| "r" | in
|
| "w" | out, out|trunc
|
| "a" | app, out|app
|
| "r+" | out|in
|
| "w+" | out|in|trunc
|
| "a+" | out|in|app, in|app
|
| "rb" | binary|in
|
| "wb" | binary|out, binary|out|trunc
|
| "ab" | binary|app, binary|out|app
|
| "r+b" | binary|out|in
|
| "w+b" | binary|out|in|trunc
|
| "a+b" | binary|out|in|app, binary|in|app
|
Se
openmode não é um dos modos listados, o open() falhar.Original:
If
openmode is not one of the modes listed, the open() fails.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Se a operação for bem-sucedido e
openmode & std::ios_base::ate != 0 aberto (o bit é definido ate), reposiciona a posição do arquivo para o final do arquivo, como se chamando std::fseek(file, 0, SEEK_END). Se o reposicionamento falhar, chama close() e retorna um ponteiro nulo para indicar falha.Original:
If the open operation succeeds and
openmode & std::ios_base::ate != 0 (the ate bit is set), repositions the file position to the end of file, as if by calling std::fseek(file, 0, SEEK_END). If the repositioning fails, calls close() and returns a null pointer to indicate failure.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Se o arquivo associado já estava aberta, retorna um ponteiro nulo imediatamente.
Original:
If the associated file was already open, returns a null pointer right away.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Parâmetros
| s | - | o nome do arquivo para abrir
Original: the file name to open The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| openmode | - | o modo de abertura de arquivo, um binário OR dos modos std::ios_base
Original: the file opening mode, a binary OR of the std::ios_base modes The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Valor de retorno
*this em caso de sucesso, um ponteiro nulo em caso de falha.Original:
*this on success, a null pointer on failure.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Notas
open() é normalmente chamado através do construtor ou a função de membro open() de std::basic_fstream.Original:
open() is typically called through the constructor or the open() member function of std::basic_fstream.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Exemplo
| Esta seção está incompleta Motivo: sem exemplo |
Veja também
| checks if the associated file is open (função pública membro) | |
esvaziará o buffer área e colocar fecha o arquivo associado Original: flushes the put area buffer and closes the associated file The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (função pública membro) | |