Re: WinInet API: Accessing a file on FTP for Reading [OT]

From: Gianni Mariani (gi2nospam_at_mariani.ws)
Date: 06/02/04


Date: 02 Jun 2004 10:16:33 EDT

Rashid wrote:
> I am using WinInet APIs to access a file on an FTP server (using
> InternetOpen, InternetConnect, FtpOpenFile). Before downloading, I
> want to make sure that the file I am accessing is not being written by
> any other process at the same time. If somebody is uploading a large
> file, I dont want my process to read partially-written file. I have
> tried FtpRenameFile (e.g. renaming file abc.txt to the same name
> abc.txt). This works in most cases and guarantees that no other
> process is accessing the file, but some ftp servers refuse to rename
> the file to same name. I can not change the name of the file. Is there
> a better alternative (like the one provided by CreateFile windows API
> through FILE_SHARE_READ, FILE_SHARE_WRITE flags)?

No.

Firstly, this is off-topic in c.l.c++ (and probably wine as well). It
is a question about ftp servers. I have no idea which forum is most
appropriate.

Having come across this problem in the past, the way I handled it was
that the client uploading the file would load the file with a temporary
name and once the transfer was complete, it would rename the file to
it's final name.

Your assertion that renaming of a file that is being uploaded seems to
work is probably wrong, I'm almost sure than on most unix/linux based
systems, the ftp server has no idea that the file is being uploaded and
will quite happily change the name of a currently uploaded file.

If you can, you should use an alternative, ftp is not so good regarding
concurrency.



Relevant Pages

  • Re: [ OT ] WinInet API: Accessing a file on FTP for Reading
    ... |I am using WinInet APIs to access a file on an FTP server (using ... | InternetOpen, InternetConnect, FtpOpenFile). ... | a better alternative (like the one provided by CreateFile windows API ...
    (alt.comp.lang.learn.c-cpp)
  • WinInet API: Accessing a file on FTP for Reading
    ... I am using WinInet APIs to access a file on an FTP server (using ... InternetOpen, InternetConnect, FtpOpenFile). ... Before downloading, I ...
    (alt.comp.lang.learn.c-cpp)
  • WinInet API: Accessing a file on FTP for Reading
    ... I am using WinInet APIs to access a file on an FTP server (using ... InternetOpen, InternetConnect, FtpOpenFile). ... Before downloading, I ...
    (microsoft.public.win32.programmer.networks)
  • Re: 500 ORT and 500 LPRT error code
    ... The erro codes you're referring to don't come from FrontPage. ... the FTP server that FrontPage is uploading to. ... Why would I get an error code from them if they dont ...
    (microsoft.public.frontpage.client)
  • Re: IIS 6 FTP problem
    ... it could be network connection issue. ... firewall between the client machines and ftp server? ... > Uploading at local works well, but it takes 2 seconds only. ... >> to the ftp server, and try upload the file at that local machine. ...
    (microsoft.public.inetserver.iis.ftp)