James Van Artsdalen wrote:
>>Date: Mon, 27 Oct 2003 18:53:25 +0100
>>From: =?UTF-8?B?QnJhbmtvIMSMaWJlag==?= <brane@xbc.nu>
>>
>>
>
>
>
>>Win32 makes no such guarantee. A file _can_ be renamed or deleted while
>>open, it just won't disappear from the directory listing until the last
>>handle is closed. It would be amazingly simple to implement this if only
>>Win32 offered a rename-through-handle function...
>>
>>
>
>OK, I see what you mean, NT has FILE_SHARE_DELETE. I didn't really
>consider any NT-only features to be really Win32, but that's being
>picky. No ugly NT API calls needed with FILE_SHARE_DELETE.
>
>FILE_SHARE_DELETE is the way to go on NT. I'll test it this evening.
>
>
This actually works out of the box with APR (see the attached test
program). If course, it won't work on Win9x. But I think it's worth a try.
--
Brane Čibej <brane_at_xbc.nu> http://www.xbc.nu/brane/
#include "../common/apr/include/apr.h"
#include "../common/apr/include/apr_file_io.h"
#include <stdio.h>
#include <stdlib.h>
#define ERR(stmt) do { \
if ((err = stmt)) { \
fprintf(stderr, "%s\n%s\n", #stmt, \
apr_strerror(err, errbuf, 1024)); \
return EXIT_FAILURE; \
} \
} while (0)
int main (void)
{
static char errbuf[1024];
static const char writebuf[] =
"wqdqwdpoihwe07812rn sp9e8fz0q293rhlq2398ztcq8347 ol3htpf0q283t"
"wqdqwdpoihwe07812rn sp9e8fz0q293rhlq2398ztcq8347 ol3htpf0q283t"
"wqdqwdpoihwe07812rn sp9e8fz0q293rhlq2398ztcq8347 ol3htpf0q283t"
"wqdqwdpoihwe07812rn sp9e8fz0q293rhlq2398ztcq8347 ol3htpf0q283t"
"wqdqwdpoihwe07812rn sp9e8fz0q293rhlq2398ztcq8347 ol3htpf0q283t"
"wqdqwdpoihwe07812rn sp9e8fz0q293rhlq2398ztcq8347 ol3htpf0q283t";
apr_status_t err;
apr_pool_t *pool;
apr_file_t *file;
apr_size_t nwrite;
if (apr_initialize())
{
fprintf(stderr, "Cannot initialize APR.\n");
return EXIT_FAILURE;
}
else
atexit(apr_terminate);
ERR(apr_pool_create(&pool, NULL));
ERR(apr_file_open(&file, "foo", APR_CREATE | APR_WRITE,
APR_OS_DEFAULT, pool));
ERR(apr_file_write_full(file, writebuf, sizeof(writebuf) - 1, &nwrite));
ERR(apr_file_remove("bar", pool));
ERR(apr_file_rename("foo", "bar", pool));
ERR(apr_file_close(file));
return EXIT_SUCCESS;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Oct 27 23:53:38 2003