Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d24cb40

Browse filesBrowse files
committed
file_size is a directory error but getting closer
1 parent 84ae2ab commit d24cb40
Copy full SHA for d24cb40

File tree

1 file changed

+16
-3
lines changed
Filter options

1 file changed

+16
-3
lines changed

‎utils/types.cpp

Copy file name to clipboardExpand all lines: utils/types.cpp
+16-3
Original file line numberDiff line numberDiff line change
@@ -115,24 +115,37 @@ Directory :: Directory (const std::string& path) {
115115
struct stat info{};
116116
stat(i.path().c_str(), &info);
117117
struct group *gr = getgrgid(info.st_gid);
118-
struct tm *created = localtime((const time_t *) info.st_ctime);
118+
auto created = posix2time(info.st_ctime);
119119
struct passwd *user = getpwuid(info.st_uid);
120120

121+
std::tm *gat = std::gmtime(&created);
122+
std::stringstream buff;
123+
buff << std::put_time(gat, "%A, %d %B %Y %H:%M");
124+
std::string created_format = buff.str();
125+
121126
std::time_t tt = decltype(i.last_write_time())::clock::to_time_t(i.last_write_time());
122127
std::tm *gmt = std::gmtime(&tt);
123128
std::stringstream buffer;
124129
buffer << std::put_time(gmt, "%A, %d %B %Y %H:%M");
125130
std::string modified_formatted = buffer.str();
126131

132+
std::string file_size;
133+
134+
if (i.is_directory()) {
135+
file_size.append(std::to_string(i.file_size()));
136+
} else {
137+
file_size.append(grey("-"));
138+
}
139+
127140
paths_h.emplace_back(
128141
File (
129142
i,
130143
meta_types,
131144
gr->gr_name,
132145
user->pw_name,
133146
modified_formatted,
134-
std::to_string(created->tm_year),
135-
std::to_string(i.file_size()),
147+
created_format,
148+
file_size,
136149
color_and_format_perms(fs::status(i.path()).permissions())
137150
)
138151
);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.