/[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 76 by werner, Mon Oct 31 21:14:11 2005 UTC revision 77 by twoaday, Mon Nov 14 15:01:01 2005 UTC
# Line 84  set_menu_state (HMENU menu, int m_uid, i Line 84  set_menu_state (HMENU menu, int m_uid, i
84  }  }
85    
86    
87    enum {
88        CDLG_FILE_OPEN = 0,
89        CDLG_FILE_SAVE = 1
90    };
91    
92  /* Use the common dialog to request a file from the user.  /* Use the common dialog to request a file from the user.
93     id can be either FILE_OPEN or FILE_SAVE.     id can be either FILE_OPEN or FILE_SAVE.
# Line 111  get_filename_dlg (HWND hwnd, int id, con Line 115  get_filename_dlg (HWND hwnd, int id, con
115      open.hwndOwner = hwnd;      open.hwndOwner = hwnd;
116      open.lpstrFile = file;      open.lpstrFile = file;
117      open.nMaxFile = sizeof (file) - 1;      open.nMaxFile = sizeof (file) - 1;
118      if (id == FILE_OPEN)      if (id == CDLG_FILE_OPEN)
119          open.Flags = OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST;          open.Flags = OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST;
120      else      else
121          open.Flags = OFN_OVERWRITEPROMPT;          open.Flags = OFN_OVERWRITEPROMPT;
122    
123      if (id == FILE_OPEN && GetOpenFileName (&open))      if (id == CDLG_FILE_OPEN && GetOpenFileName (&open))
124          return open.lpstrFile;          return open.lpstrFile;
125      else if (id == FILE_SAVE && GetSaveFileName (&open))      else if (id == CDLG_FILE_SAVE && GetSaveFileName (&open))
126          return open.lpstrFile;          return open.lpstrFile;
127            
128      return NULL;      return NULL;
# Line 128  const char* Line 132  const char*
132  get_filesave_dlg (HWND hwnd, const char *title,  get_filesave_dlg (HWND hwnd, const char *title,
133                    const char *filter, const char *name)                    const char *filter, const char *name)
134  {  {
135      return get_filename_dlg (hwnd, FILE_SAVE, title, filter, name);      return get_filename_dlg (hwnd, CDLG_FILE_SAVE, title, filter, name);
136  }  }
137    
138  const char *  const char *
139  get_fileopen_dlg (HWND hwnd, const char *title, const char *filter,  get_fileopen_dlg (HWND hwnd, const char *title, const char *filter,
140                    const char *name)                    const char *name)
141  {  {
142      return get_filename_dlg (hwnd, FILE_OPEN, title, filter, name);      return get_filename_dlg (hwnd, CDLG_FILE_OPEN, title, filter, name);
143  }  }
144    
145    
# Line 314  dir_exist_check (const char *dir) Line 318  dir_exist_check (const char *dir)
318  }  }
319    
320    
321  /* Return the file size of the given file. */  /* Return the file size of the given file @fname. */
322  size_t  DWORD
323  get_file_size (const char *fname)  get_file_size (const char *fname)
324  {  {
325      size_t fsize;      DWORD fsize;
326      HANDLE fh;      HANDLE fh;
327    
328      fh = CreateFile( fname, GENERIC_READ, FILE_SHARE_READ,      fh = CreateFile (fname, GENERIC_READ, FILE_SHARE_READ,
329                      NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );                       NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
330      if( fh == INVALID_HANDLE_VALUE )      if (fh == INVALID_HANDLE_VALUE)
331          return 0;          return 0;
332      fsize = GetFileSize( fh, NULL );      fsize = GetFileSize (fh, NULL);
333      if( fsize == 0xFFFFFFFF )      if (fsize == 0xFFFFFFFF)
334          fsize = 0;          fsize = 0;
335      CloseHandle( fh );      CloseHandle (fh);
336      return fsize;      return fsize;
337  } /* get_file_size */  }
338    
339    
340  int  int

Legend:
Removed from v.76  
changed lines
  Added in v.77

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26