void FH_destroy(FileHandle *self) { FH_Close(self); DECREF(self->path); SUPER_DESTROY(self, FILEHANDLE); // Decrement count of FileHandle objects in existence. FH_object_count--; }
void FH_Destroy_IMP(FileHandle *self) { FileHandleIVARS *const ivars = FH_IVARS(self); FH_Close(self); DECREF(ivars->path); SUPER_DESTROY(self, FILEHANDLE); // Decrement count of FileHandle objects in existence. FH_object_count--; }
void OutStream_Close_IMP(OutStream *self) { OutStreamIVARS *const ivars = OutStream_IVARS(self); if (ivars->file_handle) { S_flush(self, ivars); if (!FH_Close(ivars->file_handle)) { RETHROW(INCREF(Err_get_error())); } DECREF(ivars->file_handle); ivars->file_handle = NULL; } }
static void test_Slurp_File(TestBatch *batch) { Folder *folder = (Folder*)RAMFolder_new(NULL); FileHandle *fh = Folder_Open_FileHandle(folder, &foo, FH_CREATE | FH_WRITE_ONLY); ByteBuf *contents; FH_Write(fh, "stuff", 5); FH_Close(fh); DECREF(fh); contents = Folder_Slurp_File(folder, &foo); TEST_TRUE(batch, BB_Equals_Bytes(contents, "stuff", 5), "Slurp_File"); DECREF(contents); DECREF(folder); }