119 |
else |
else |
120 |
memset (file, 0, sizeof (file)); |
memset (file, 0, sizeof (file)); |
121 |
if (!filter) |
if (!filter) |
122 |
filter = _("All Files (*.*)\0*.*\0\0"); |
filter = "All Files (*.*)\0*.*\0\0"; |
123 |
/* XXX: problem with gettext because of the 'artificial' |
/* XXX: problem with gettext because of the 'artificial' |
124 |
double string termination!. */ |
double string termination!. */ |
125 |
memset (&open, 0, sizeof (open)); |
memset (&open, 0, sizeof (open)); |
309 |
} |
} |
310 |
|
|
311 |
|
|
312 |
|
/* Generate a file name from a special dirctory. */ |
313 |
|
char* |
314 |
|
make_special_filename (int folder, const char *file, const char *ext) |
315 |
|
{ |
316 |
|
BOOL ec; |
317 |
|
char path[MAX_PATH], *p; |
318 |
|
size_t n=0; |
319 |
|
|
320 |
|
/* MSDN: buf must be at least MAX_PATH=256 bytes */ |
321 |
|
ec = SHGetSpecialFolderPath (HWND_DESKTOP, path, folder, TRUE); |
322 |
|
if (ec != 1) { |
323 |
|
log_debug ("SHGetSpecialFolderPath() failed\r\n", (int)GetLastError ()); |
324 |
|
return NULL; |
325 |
|
} |
326 |
|
|
327 |
|
n = strlen (path)+1; |
328 |
|
if (file) |
329 |
|
n += strlen (file)+1; |
330 |
|
if (ext) |
331 |
|
n += strlen (ext)+1; |
332 |
|
p = new char[n+2]; |
333 |
|
if (!p) |
334 |
|
BUG (0); |
335 |
|
memset (p, 0, n+2); |
336 |
|
strcpy (p, path); |
337 |
|
if (file) { |
338 |
|
strcat (p, "\\"); |
339 |
|
strcat (p, file); |
340 |
|
} |
341 |
|
if (ext) |
342 |
|
strcat (p, ext); |
343 |
|
return p; |
344 |
|
} |
345 |
|
|
346 |
|
|
347 |
/* return 0 if the file @fname exists, otherwise >0. */ |
/* return 0 if the file @fname exists, otherwise >0. */ |
348 |
int |
int |
349 |
file_exist_check (const char *fname) |
file_exist_check (const char *fname) |
389 |
} |
} |
390 |
|
|
391 |
|
|
|
int |
|
|
init_file_lock( LOCK *ctx, const char *file ) |
|
|
{ |
|
|
|
|
|
ctx->size = get_file_size( file ); |
|
|
ctx->file = m_strdup( file ); |
|
|
ctx->fh = CreateFile( file, GENERIC_READ, FILE_SHARE_READ, NULL, |
|
|
OPEN_ALWAYS, 0, NULL ); |
|
|
if( ctx->fh == INVALID_HANDLE_VALUE ) |
|
|
return WPTERR_GENERAL; |
|
|
if( LockFile( ctx->fh, 0, 0, ctx->size, 0 ) == FALSE ) { |
|
|
CloseHandle( ctx->fh ); |
|
|
ctx->fh = INVALID_HANDLE_VALUE; |
|
|
ctx->size = 0; |
|
|
free( ctx->file ); |
|
|
return WPTERR_GENERAL; |
|
|
} |
|
|
return 0; |
|
|
} /* init_file_lock */ |
|
|
|
|
|
|
|
|
void |
|
|
release_file_lock( LOCK *ctx ) |
|
|
{ |
|
|
free_if_alloc( ctx->file ); |
|
|
ctx->file = NULL; |
|
|
ctx->size = 0; |
|
|
CloseHandle( ctx->fh ); |
|
|
} /* release_file_lock */ |
|
|
|
|
|
|
|
392 |
/* Start a dialog with the exception that before it is checked that the |
/* Start a dialog with the exception that before it is checked that the |
393 |
dialog is not already openened. */ |
dialog is not already openened. */ |
394 |
int |
int |