🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #17095

Re: get file specs

#17095
From: DeKayA
Date: Wed, 09 Apr 2003 03:25
57 lines
2348 bytes
Surely there is a cleaner way...
void __fastcall TVIPForm::GetFileSpecs(String Path)
{   //Surely there is a better way...
  String FileSize;
  String DatenTime;
  int Year;
  int Month;
  int Day;
  int Hour;
  int Min;
  int Sec;

  if(Path.IsEmpty()) //true if the AnsiString is empty.
    return "No File Found";

  TSearchRec sr; //int Time, int Size int Attr, AnsiString Name, int
ExcludeAttr, int FindHandle, _WIN32_FIND_DATAA FindData
  if(FindFirst(Path , faAnyFile, sr) == 0)
    {
      FileSize = IntToStr(sr.Size);
      DatenTime = sr.Time;    //Need to learn how to extract
    }

  FindClose(sr);



 //All this to get the Date & Time..........

   FILE *stream;
   std::ftime ft;

   if ((stream = fopen(Path.c_str(), "r")) == NULL)
   {
       return;  //  Cannot open output file.
   }

   getftime(fileno(stream), &ft); //fileno is handle of stream

   Year  = ft.ft_year+1980;
   Month = ft.ft_month;
   Day   = ft.ft_day;

   Hour = ft.ft_hour;
   Min  = ft.ft_min;
   Sec  = ft.ft_tsec *2;

   fclose(stream);

   MessageBar->Text = "  " + FileSize + " Bytes    " + IntToStr(Month)
+ "/" + IntToStr(Day) + "/" + IntToStr(Year) + "  " + IntToStr(Hour) +
":" + IntToStr(Min) + ":" + IntToStr(Sec);

return;
}

//============================================================
Technical Details
Message-ID: <3e939179.20005948@forums.inprise.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!207.217.77.43.MISMATCH!newsfeed1.earthlink.net!newsfeed.earthlink.net!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <3e931a5f.198205@forums.inprise.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,d799131d9f6242d1
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-04-08 20:28:51 PST
From: DeKayA@bellsouth.net
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: get  file specs
Date: Wed, 09 Apr 2003 03:25:04 GMT
Message-ID: <3e939179.20005948@forums.inprise.com>
References: <3e931a5f.198205@forums.inprise.com>
X-Newsreader: Forte Agent 1.5/32.452
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 209.214.6.225
X-Trace: newsgroups.borland.com 1049858769 209.214.6.225 (8 Apr 2003 20:26:09 -0800)
Lines: 58
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!207.217.77.43.MISMATCH!newsfeed1.earthlink.net!newsfeed.earthlink.net!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail