/[winpt]/trunk/Src/wptW32API.cpp
ViewVC logotype

Diff of /trunk/Src/wptW32API.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 129 by twoaday, Fri Dec 30 13:56:10 2005 UTC revision 167 by twoaday, Thu Jan 26 10:17:17 2006 UTC
# Line 119  get_filename_dlg (HWND hwnd, int id, con Line 119  get_filename_dlg (HWND hwnd, int id, con
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));
# Line 309  make_filename (const char *path, const c Line 309  make_filename (const char *path, const c
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)
# Line 354  get_file_size (const char *fname) Line 389  get_file_size (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

Legend:
Removed from v.129  
changed lines
  Added in v.167

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26