Skip to content

Commit 59cc0ed

Browse files
committed
[utils] add implementation of util_entry for rs232 that looks like msdos.
1 parent 1d73914 commit 59cc0ed

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

lib/utils/utils.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,54 @@ std::string util_crunch(std::string filename)
220220

221221
return basename + ext;
222222
}
223+
#ifdef BUILD_RS232
224+
std::string util_entry(std::string crunched, size_t fileSize, bool is_dir, bool is_locked)
225+
{
226+
size_t ext_pos = crunched.find(".");
227+
std::string basename = crunched.substr(0, ext_pos);
228+
std::string ext = crunched.substr(ext_pos + 1);
229+
char e[80];
230+
unsigned char month = 1;
231+
unsigned char day = 1;
232+
unsigned int year = 24;
233+
unsigned char hour = 12;
234+
unsigned char minutes = 0;
235+
char ampm = 'p';
236+
237+
memset(e,0,sizeof(e));
238+
239+
if (is_dir)
240+
{
241+
sprintf(e,
242+
"%-8s %-3s %-10s %2u-%02u-%02u %2u:%02u%c",
243+
basename.c_str(),
244+
ext.c_str(),
245+
"<DIR>",
246+
month,
247+
day,
248+
year,
249+
hour,
250+
minutes,
251+
ampm);
252+
}
253+
else
254+
{
255+
sprintf(e,
256+
"%-8s %-3s %10u %2u-%02u-%02u %2u:%02u%c",
257+
basename.c_str(),
258+
ext.c_str(),
259+
fileSize,
260+
month,
261+
day,
262+
year,
263+
hour,
264+
minutes,
265+
ampm);
266+
}
223267

268+
return std::string(e);
269+
}
270+
#else
224271
std::string util_entry(std::string crunched, size_t fileSize, bool is_dir, bool is_locked)
225272
{
226273
std::string returned_entry = " ";
@@ -265,6 +312,7 @@ std::string util_entry(std::string crunched, size_t fileSize, bool is_dir, bool
265312

266313
return returned_entry;
267314
}
315+
#endif /* !defined BUILD_RS232 */
268316

269317
std::string util_long_entry(std::string filename, size_t fileSize, bool is_dir)
270318
{

0 commit comments

Comments
 (0)