forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


FTP.DSU that comes with VDS5

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced Help for VDS 5 & Up
View previous topic :: View next topic  
Author Message
Rubes_sw
Valued Contributor
Valued Contributor


Joined: 11 Jun 2001
Posts: 625
Location: Northern Ireland

PostPosted: Thu Sep 11, 2003 12:36 pm    Post subject: FTP.DSU that comes with VDS5 Reply with quote

Does anyone know (codescript Very Happy, since you might have a good idea) about using the FTP.DSU that comes with VDS5.

It returns the file size, is there anyway to modify the code to also return the file date/time ?

Any ideas, modified code would be great !

Nathan
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Thu Sep 11, 2003 2:58 pm    Post subject: Reply with quote

hi Rubes,
I know I am not CodeScript but I may be able to answer your question. Inside FTP.dsc there is two functions called FTP_DIRLIST and FTP_ADDDIR. In the FTP_DIRLIST function there is a VDS variable called %B that is defined as %B = @fill(318). %B is a WIN32_FIND_DATA structure. 3 members of that structure are FILETIME structures. You will need FileTimeToSystemTime to convert those FILETIME structures to a human readable Date/Time stamp. The following code shows you what you will need to add/update to the FTP.dsc file to get the Date/Time stamps.


Code:
:FTP_DIRLIST
# %2 is file spec
  %R =
  if %2
    %B = @fill(318)
    %%ftp_findhandle = @lib(WININET,FtpFindFirstFileA,int:,%%ftp_handle,str:%2,@addr("%B"),0,0)
    if @not(@zero(%%ftp_findhandle))
      gosub ftp_adddir
      while @lib(WININET,InternetFindNextFileA,bool:,%%ftp_findhandle,@addr("%B"))
        gosub ftp_adddir
      wend
    end
    %Z = @lib(WININET,InternetCloseHandle,bool:,%%ftp_findhandle)
  else
    error 2
  end
  exit %R

:FTP_ADDDIR
  # For some reason the Win32 API does not update ftCreationTime and ftLastAccessTime
  # for directories.  I added it anyway
  GoSub FTP_GETFILETIME
  %N = @adjust(@substr(%B,45,160))
  %A = @hex(@val(@substr(%B,1,4)))
  %Z = @fadd(@fmul(@val(@substr(%B,29,32)),4294967296),@val(@substr(%B,33,36)))
  if @equal(@substr(%A,3),1)

    %R = %R<dir>     %N@fsep()%%FileTime@cr()
  else
    %R = %R@fill(8,%Z)  %N@fsep()%%FileTime@cr()
  end
  exit
 
:FTP_GETFILETIME
  rem BOOL FileTimeToSystemTime(

    rem CONST FILETIME *  lpFileTime,   // pointer to file time to convert
    rem LPSYSTEMTIME  lpSystemTime    // pointer to structure to receive system time 
   rem );   
  %%DateSep = @datetime(/)
  %%TimeSep = @datetime(Smile
  # The days of the week list
  List create,25
  List Add,25,Sunday
  List Add,25,Monday
  List Add,25,Tuesday
  List Add,25,Wednesday
  List Add,25,Thursday
  List Add,25,Friday
  List Add,25,Saturday
 
  # ftCreationTime
  %C = @substr(%B,5,12)
  # ftLastAccessTime
  %L = @substr(%B,13,20)
  # ftLastWriteTime
  %W = @substr(%B,21,2Cool
  # System time structure
  %S = @binary(WORD,0)@binary(WORD,0)@binary(WORD,0)@binary(WORD,0)@binary(WORD,0)@binary(WORD,0)@binary(WORD,0)@binary(WORD,0)
  loadlib kernel32.dll
  %%Ret = @lib(kernel32,FileTimeToSystemTime,BOOL:,@addr("%C"),@addr("%S"))
  %%wYear = @val(@SubStr(%S,1,2))
  %%wMonth = @val(@SubStr(%S,3,4))
  %%wDayOfWeek = @Item(25,@val(@SubStr(%S,5,6)))
  %%wDay = @val(@SubStr(%S,7,Cool)
  %%wHour = @val(@SubStr(%S,9,10))
  %%wMinute = @val(@SubStr(%S,11,12))
  %%wSecond = @val(@SubStr(%S,13,14))
  %%wMilliseconds = @val(@SubStr(%S,15,16))
  %%ftCreationTime = %%wDayOfWeek %%wMonth%%DateSep%%wDay%%DateSep%%wYear %%wHour%%TimeSep%%wMinute%%TimeSep%%wSecond%%TimeSep%%wMilliseconds
  %%Ret = @lib(kernel32,FileTimeToSystemTime,BOOL:,@addr("%L"),@addr("%S"))
  %%wYear = @val(@SubStr(%S,1,2))
  %%wMonth = @val(@SubStr(%S,3,4))
  %%wDayOfWeek = @Item(25,@val(@SubStr(%S,5,6)))
  %%wDay = @val(@SubStr(%S,7,Cool)
  %%wHour = @val(@SubStr(%S,9,10))
  %%wMinute = @val(@SubStr(%S,11,12))
  %%wSecond = @val(@SubStr(%S,13,14))
  %%wMilliseconds = @val(@SubStr(%S,15,16))
  %%ftLastAccessTime = %%wDayOfWeek %%wMonth%%DateSep%%wDay%%DateSep%%wYear %%wHour%%TimeSep%%wMinute%%TimeSep%%wSecond%%TimeSep%%wMilliseconds
  %%Ret = @lib(kernel32,FileTimeToSystemTime,BOOL:,@addr("%W"),@addr("%S"))
  %%wYear = @val(@SubStr(%S,1,2))
  %%wMonth = @val(@SubStr(%S,3,4))
  %%wDayOfWeek = @Item(25,@val(@SubStr(%S,5,6)))
  %%wDay = @val(@SubStr(%S,7,Cool)
  %%wHour = @val(@SubStr(%S,9,10))
  %%wMinute = @val(@SubStr(%S,11,12))
  %%wSecond = @val(@SubStr(%S,13,14))
  %%wMilliseconds = @val(@SubStr(%S,15,16))
  %%ftLastWriteTime = %%wDayOfWeek %%wMonth%%DateSep%%wDay%%DateSep%%wYear %%wHour%%TimeSep%%wMinute%%TimeSep%%wSecond%%TimeSep%%wMilliseconds
  %%FileTime = %%ftCreationTime@fsep()%%ftLastAccessTime@fsep()%%ftLastWriteTime
  FreeLib kernel32
  List clear,25
  List close,25
exit 


Anyway have fun and I hope this helps.

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Thu Sep 11, 2003 6:45 pm    Post subject: Reply with quote

Mindpower You are the boss in API usage area. I am just learning.
I have never tried this FTP example.
But time converison yes, mindpower has put up nice code there. I have implemented conversion among filetime,systemtime,local time etc in two examples:
http://www.vdsworld.com/index.php?page=download&fileid=330
http://www.vdsworld.com/index.php?page=download&fileid=323

_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Thu Sep 11, 2003 8:06 pm    Post subject: Reply with quote

CodeScript and everyone,
Think nothing of it. This is what I do all day every day Wink My code above is a little convoluted. I was trying to show what all the variables are and what they are for so you guys could reproduce the code. I used a bunch of long variable names here. If anyone is using this code you can definately shorten this alot and make it more readable and stream line it abit.

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Fri Sep 12, 2003 2:23 am    Post subject: Reply with quote

mindpower wrote:
CodeScript and everyone,
Think nothing of it. This is what I do all day every day

I do only in my freetime as a hobby etc Smile when it runs out I too run from here Smile . I just acknowledged you are an expert in the field because of gadget and the fact that you have chosen C++ as your primary programming langauge which needs real depth of programming knowledge to work with.

I always try to use "local" varaibles as far as possible to conserve varaibles and also it is a little faster I think. But that may not make much sense without extensive comments when posting as example code as mindpower said especially for those who don't have access to/unfamiliar to W32.hlp or msdn.

_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
jules
Professional Member
Professional Member


Joined: 14 Sep 2001
Posts: 1043
Location: Cumbria, UK

PostPosted: Fri Sep 12, 2003 8:29 am    Post subject: Reply with quote

For what it's worth, there is no speed or size penalty in using long variable names in a script. It might take a bit longer to compile, but not at runtime. Variables are all compiled down to a byte reference, which is why the total number is currently limited to 256.
_________________
The Tech Pro
www.tech-pro.net
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced Help for VDS 5 & Up All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group