MCPcopy Create free account
hub / github.com/cinder/Cinder / qoiWritePath

Function qoiWritePath

src/cinder/ImageTargetFileQoi.cpp:40–65  ·  view source on GitHub ↗

Cross-platform wrapper for qoi_write that handles Unicode paths properly

Source from the content-addressed store, hash-verified

38
39// Cross-platform wrapper for qoi_write that handles Unicode paths properly
40int qoiWritePath( const fs::path &path, const void *data, const qoi_desc *desc )
41{
42#if defined( CINDER_MSW )
43 FILE *f = _wfopen( path.wstring().c_str(), L"wb" );
44#else
45 FILE *f = fopen( path.string().c_str(), "wb" );
46#endif
47
48 if( ! f )
49 return 0;
50
51 int size;
52 void *encoded = qoi_encode( data, desc, &size );
53 if( ! encoded ) {
54 fclose( f );
55 return 0;
56 }
57
58 fwrite( encoded, 1, size, f );
59 fflush( f );
60 int err = ferror( f );
61 fclose( f );
62
63 free( encoded );
64 return err ? 0 : size;
65}
66
67} // anonymous namespace
68

Callers 1

finalizeMethod · 0.85

Calls 4

qoi_encodeFunction · 0.85
wstringMethod · 0.80
c_strMethod · 0.45
stringMethod · 0.45

Tested by

no test coverage detected