bool RWFile::open(const char* path, ExistingFileAction efa) { if (efa.Value == Nonexistent.Value && Exists(path)) { state.error = true; return false; } char mode_string[8]; auto base_string = [&] { switch (efa.Value) { case Nonexistent.Value: case Clear.Value: return "w+"; case Append.Value: return "a+"; case Prepend.Value: // "r+" will fail if the file doesn't exist. return Exists(path) ? "r+" : "w+"; } assert(false); return "r+"; }(); strcpy_safe(mode_string, base_string); if (!efa.Text) strcat_safe(mode_string, "b"); return open_impl(path, mode_string); }
bool Th105DataArchiveExtractor::open(const char *filename) { ASSERT(fp == NULL); ASSERT(file_list.empty()); ASSERT(comp_data_size == 0); ASSERT(file_size == 0); if(filename == NULL || filename[0] == '\0' || strlen(filename) >= sizeof(this->filename)){ return false; } fp = fopen(filename,"rb"); if(!open_impl(file_list, file_size, comp_data_size, fp)) { if(fp != NULL) { fclose(fp); fp = NULL; } file_list.clear(); comp_data_size = 0; file_size = 0; return false; } strcpy(this->filename, filename); return true; }
static int aead_chacha20_poly1305_open(const EVP_AEAD_CTX *ctx, uint8_t *out, size_t *out_len, size_t max_out_len, const uint8_t *nonce, size_t nonce_len, const uint8_t *in, size_t in_len, const uint8_t *ad, size_t ad_len) { if (nonce_len != 12) { OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_UNSUPPORTED_NONCE_SIZE); return 0; } return open_impl(poly1305_update, ctx, out, out_len, max_out_len, nonce, in, in_len, ad, ad_len); }
static int aead_chacha20_poly1305_old_open( const EVP_AEAD_CTX *ctx, uint8_t *out, size_t *out_len, size_t max_out_len, const uint8_t *nonce, size_t nonce_len, const uint8_t *in, size_t in_len, const uint8_t *ad, size_t ad_len) { if (nonce_len != 8) { OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_UNSUPPORTED_NONCE_SIZE); return 0; } uint8_t nonce_96[12]; memset(nonce_96, 0, 4); memcpy(nonce_96 + 4, nonce, 8); return open_impl(poly1305_update_old, ctx, out, out_len, max_out_len, nonce_96, in, in_len, ad, ad_len); }
void open(U0& u0, const U1& u1, const U2& u2) { open_impl(detail::forward<Device, U0>(), u0, u1, u2); }
void open(U0& u0) { open_impl(detail::forward<Device, U0>(), u0); }
void open(const U0& u0, const U1& u1) { open_impl(detail::forward<Device, U0>(), u0, u1); }
stream(const U0& u0) { open_impl(detail::forward<Device, U0>(), u0); }
void open(const U0& u0) { open_impl(detail::forward<T, U0>(), u0); }
stream_buffer(U0& u0, const U1& u1, const U2& u2) { open_impl(detail::forward<T, U0>(), u0, u1, u2); }
stream_buffer(U0& u0) { open_impl(detail::forward<T, U0>(), u0); }
stream_buffer(const U0& u0, const U1& u1) { open_impl(detail::forward<T, U0>(), u0, u1); }
void open(U0& u0, const U1& u1) { open_impl(detail::forward<T, U0>(), u0, u1); }
bool File::open(const char* path, TextType) { return open_impl(path, "r"); }
bool File::open(const char* path) { return open_impl(path, "rb"); }