ETP FOLDER size

Found a bug in "Everything"? report it here
Gisle Vanem
Posts: 14
Joined: Mon May 04, 2015 10:30 am

ETP FOLDER size

Postby Gisle Vanem » Mon Jun 19, 2017 2:22 pm

Experimenting with remote queries using the ETP protocol, I've noticed the size reported on a FOLDER, is extremely large.
In my case a c:\Windows\Panter\ folder contains 18446744073709551615 bytes. Which is approx. 15 Etta Bytes!!

Tested using this test-etp.bat file:
@echo off
echo USER foo:bar > etp-commands
echo QUOTE FEAT >> etp-commands
echo QUOTE EVERYTHING SEARCH setup*.exe >> etp-commands
echo QUOTE EVERYTHING PATH_COLUMN 1 >> etp-commands
echo QUOTE EVERYTHING SIZE_COLUMN 1 >> etp-commands
echo QUOTE EVERYTHING DATE_MODIFIED_COLUMN 1 >> etp-commands
echo QUOTE EVERYTHING QUERY >> etp-commands
echo BYE >> etp-commands
ftp -n -s:etp-commands 10.0.0.37


Some of the responses:
ftp> QUOTE EVERYTHING QUERY
200-Query results
RESULT_COUNT 23
PATH C:\Windows\Panther
SIZE 18446744073709551615 << !!
DATE_MODIFIED 131401049909872229
FOLDER setup.exe


I'm using the latest 1.4.1.877 (x86) version on an Intel Atom laptop.

Gisle Vanem
Posts: 14
Joined: Mon May 04, 2015 10:30 am

Re: ETP FOLDER size

Postby Gisle Vanem » Mon Jun 19, 2017 5:41 pm

It seems the value I got; 18446744073709551615
is (unsigned __int64)-1). I assume you have used this value to initialise an unknown folder-size.
(just to differentiate a folder-size of 0 byte). But then forgot to fill in the real folder-size. Or something like that, no?

void
Site Admin
Posts: 3431
Joined: Fri Oct 16, 2009 11:31 pm

Re: ETP FOLDER size

Postby void » Mon Jun 19, 2017 11:49 pm

Everything uses 18446744073709551615 to display unknown size.

I'll review the ETP server/client displaying:
SIZE 18446744073709551615

and instead displaying:
SIZE

Gisle Vanem
Posts: 14
Joined: Mon May 04, 2015 10:30 am

Re: ETP FOLDER size

Postby Gisle Vanem » Tue Jun 20, 2017 9:49 am

Ok, that would be a good fix.

I have a question on the time-zone. With this
DATE_MODIFIED 131401049909872229, I use this code to convert to a time_t:

Code: Select all

/* Number of seconds between the beginning of the Windows epoch
 * (Jan. 1, 1601) and the Unix epoch (Jan. 1, 1970).
 */
#define DELTA_EPOCH_IN_SEC 11644473600
static time_t FILETIME_to_time_t (UINT64 ft)
{
  ft /= 10000000;            /* from 100 nano-sec periods to sec */
  ft -= DELTA_EPOCH_IN_SEC;  /* from Windows epoch to Unix epoch */
  return (ft);
}
...
  UINT64 ft;
  if (sscanf(ctx->rx_ptr, "DATE_MODIFIED %I64u", &ft) == 1) {
      ctx->mtime = FILETIME_to_time_t (ft);
      printf ("mtime: %.24s", ctime(&ctx->mtime));     
  }


But the printed time I get seems off by 2 hours compared to what your GUI is showing me.
Please advice.

void
Site Admin
Posts: 3431
Joined: Fri Oct 16, 2009 11:31 pm

Re: ETP FOLDER size

Postby void » Tue Jun 20, 2017 12:10 pm

Everything uses SystemTimeToTzSpecificLocalTime to adjust filetimes to the current local time (taking daylight saving time into account) which is why you might be seeing the time difference.

If possible, please use FileTimeToSystemTime and SystemTimeToTzSpecificLocalTime.

Gisle Vanem
Posts: 14
Joined: Mon May 04, 2015 10:30 am

Re: ETP FOLDER size

Postby Gisle Vanem » Tue Jun 20, 2017 3:08 pm

Thanks for the information. But that just proved more complex. With this:

Code: Select all

static time_t FILETIME_to_time_t (const FILETIME *_ft)
{
  SYSTEMTIME st, lt;
  struct tm  tm;

  if (!FileTimeToSystemTime(_ft,&st) ||
      !SystemTimeToTzSpecificLocalTime(NULL,&st,&lt))
     return (0);

  memset (&tm, '\0', sizeof(tm));
  tm.tm_year  = lt.wYear - 1900;
  tm.tm_mon   = lt.wMonth - 1;
  tm.tm_mday  = lt.wDay;
  tm.tm_hour  = lt.wHour;
  tm.tm_min   = lt.wMinute;
  tm.tm_sec   = lt.wSecond;
  tm.tm_isdst = -1;
  return mktime (&tm);
}
...
  FILETIME ft;
  if (sscanf(ctx->rx_ptr, "DATE_MODIFIED %I64u", (UINT64*)&ft) == 1)
  {
    ctx->mtime = FILETIME_to_time_t (&ft);
    printf (ctx, "mtime: %.24s", ctime(&ctx->mtime));
  }

it seems to give the same as in your ETP-dialogue.
But what if the ETP-server is in another time-zone? AFAICS, there's no FTP-command for zone-info.

void
Site Admin
Posts: 3431
Joined: Fri Oct 16, 2009 11:31 pm

Re: ETP FOLDER size

Postby void » Wed Jun 21, 2017 6:56 am

The FILETIME used in ETP is in UTC.

SystemTimeToTzSpecificLocalTime should be used on the client to convert to a local time.


Return to “Bug report”