MCPcopy Create free account
hub / github.com/MonaSolutions/MonaServer / WriteDirectoryEntry

Method WriteDirectoryEntry

MonaCore/sources/HTTP/HTTP.cpp:344–362  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

342}
343
344void HTTP::WriteDirectoryEntry(BinaryWriter& writer,const string& serverAddress,const string& path,const File& entry) {
345 string size,date;
346 if (entry.isFolder())
347 size.assign("-");
348 else if (entry.size()<1024)
349 String::Format(size, entry.size());
350 else if (entry.size() < 1048576)
351 String::Format(size, Format<double>("%.1fk",entry.size()/1024.0));
352 else if (entry.size() < 1073741824)
353 String::Format(size, Format<double>("%.1fM",entry.size()/1048576.0));
354 else
355 String::Format(size, Format<double>("%.1fG",entry.size()/1073741824.0));
356
357 writer.write(EXPAND("<tr><td><a href=\"http://")).write(serverAddress).write(path).write('/')
358 .write(entry.name()).write(entry.isFolder() ? "/\">" : "\">")
359 .write(entry.name()).write(entry.isFolder() ? "/" : "").write(EXPAND("</a></td><td>&nbsp;"))
360 .write(Date(entry.lastModified()).toString("%d-%b-%Y %H:%M", date)).write(EXPAND("</td><td align=right>&nbsp;&nbsp;"))
361 .write(size).write(EXPAND("</td></tr>\n"));
362}
363
364/// Cookie Writer class for writing Set-Cookie HTTP headers when client.properties(key, value, {expires=...}) is called
365/// This implementation is based on RFC 6265 (but does not use 'Max-Age')

Callers

nothing calls this directly

Calls 6

FormatClass · 0.85
DateClass · 0.85
isFolderMethod · 0.80
lastModifiedMethod · 0.80
sizeMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected