MCPcopy Create free account
hub / github.com/SpartanJ/eepp / importCSS

Method importCSS

src/eepp/ui/css/stylesheetparser.cpp:242–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

240}
241
242std::string StyleSheetParser::importCSS( std::string path,
243 std::vector<std::string>& importedList ) {
244 if ( String::startsWith( path, "file://" ) ) {
245 path = path.substr( 7 );
246 }
247
248 if ( FileSystem::fileExists( path ) ) {
249 ScopedBuffer buffer;
250
251 if ( FileSystem::fileGet( path, buffer ) ) {
252 importedList.push_back( path );
253 return std::string( reinterpret_cast<const char*>( buffer.get() ), buffer.size() );
254 }
255 } else if ( String::startsWith( path, "http://" ) || String::startsWith( path, "https://" ) ) {
256 Http::Response response = Http::get( URI( path ), Seconds( 5 ) );
257 if ( response.getStatus() == Http::Response::Status::Ok ) {
258 importedList.push_back( path );
259 return response.getBody();
260 }
261 } else if ( VFS::instance()->fileExists( path ) ) {
262 IOStream* stream = VFS::instance()->getFileFromPath( path );
263 ScopedBuffer buffer( stream->getSize() );
264 stream->read( reinterpret_cast<char*>( buffer.get() ), buffer.size() );
265 importedList.push_back( path );
266 return std::string( reinterpret_cast<const char*>( buffer.get() ) );
267 } else {
268 if ( PackManager::instance()->isFallbackToPacksActive() ) {
269 Pack* pack = PackManager::instance()->exists( path );
270
271 if ( std::find( importedList.begin(), importedList.end(), path ) ==
272 importedList.end() ) {
273 if ( NULL != pack ) {
274 Log::debug( "Loading css from pack: %s", path.c_str() );
275 ScopedBuffer buffer;
276 if ( pack->isOpen() && pack->extractFileToMemory( path, buffer ) ) {
277 importedList.push_back( path );
278 return std::string( reinterpret_cast<const char*>( buffer.get() ) );
279 }
280 }
281 }
282 }
283 }
284
285 return std::string();
286}
287
288void StyleSheetParser::mediaParse( std::string& css, ReadState& rs, std::size_t& pos,
289 std::string& buffer, std::vector<std::string>& importedList ) {

Callers

nothing calls this directly

Calls 15

SecondsFunction · 0.85
findFunction · 0.85
debugFunction · 0.85
substrMethod · 0.80
push_backMethod · 0.80
getFileFromPathMethod · 0.80
c_strMethod · 0.80
getMethod · 0.45
sizeMethod · 0.45
getStatusMethod · 0.45
getBodyMethod · 0.45
fileExistsMethod · 0.45

Tested by

no test coverage detected