MCPcopy Create free account
hub / github.com/aseprite/laf / open_stream

Function open_stream

ft/stream.cpp:40–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40FT_Stream open_stream(const std::string& utf8Filename)
41{
42 FT_Stream stream = nullptr;
43 stream = (FT_Stream)malloc(sizeof(*stream));
44 if (!stream)
45 return nullptr;
46 memset(stream, 0, sizeof(*stream));
47
48 LOG(VERBOSE, "FT: Loading font '%s'...", utf8Filename.c_str());
49
50 FILE* file = base::open_file_raw(utf8Filename, "rb");
51 if (!file) {
52 free(stream);
53 LOG(VERBOSE, "FAIL\n");
54 return nullptr;
55 }
56
57 fseek(file, 0, SEEK_END);
58 stream->size = (unsigned long)ftell(file);
59 if (!stream->size) {
60 fclose(file);
61 free(stream);
62 LOG(VERBOSE, "FAIL\n");
63 return nullptr;
64 }
65 fseek(file, 0, SEEK_SET);
66
67 stream->descriptor.pointer = file;
68 stream->base = nullptr;
69 stream->pos = 0;
70 stream->read = ft_stream_io;
71 stream->close = ft_stream_close;
72
73 LOG(VERBOSE, "OK\n");
74 return stream;
75}
76
77} // namespace ft

Callers 1

openMethod · 0.85

Calls 2

open_file_rawFunction · 0.85
LOGFunction · 0.50

Tested by

no test coverage detected