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 |
542 |
} |
} |
543 |
|
|
544 |
|
|
545 |
|
/* Generate a temporary file name by using the users |
546 |
|
temp path and optionally a name @name provided by the caller. |
547 |
|
Return value: 0 on success. */ |
548 |
|
int |
549 |
|
get_temp_name (char *buf, DWORD buflen, const char *name) |
550 |
|
{ |
551 |
|
char tmp[32]; |
552 |
|
|
553 |
|
if (!name) { |
554 |
|
sprintf (tmp, "%08lX", GetTickCount ()); |
555 |
|
name = tmp; |
556 |
|
} |
557 |
|
if (!GetTempPath (buflen - strlen (name) -2, buf)) { |
558 |
|
log_debug ("GetTempPath() failed ec=%d\n", (int)GetLastError ()); |
559 |
|
return -1; |
560 |
|
} |
561 |
|
strcat (buf, name); |
562 |
|
return 0; |
563 |
|
} |
564 |
|
|
565 |
|
|
566 |
struct reminder_hd_s { |
struct reminder_hd_s { |
567 |
int msecs; |
int msecs; |
568 |
HWND dlg; |
HWND dlg; |