X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fvideo_output%2Fsnapshot.c;h=0f2c93817574b013322e03f6b419fd33d4345590;hb=f8bc940945d6b889303ad34edcdf4f471b228b51;hp=f6beb19a7995858e03db1090851c138d56a8a183;hpb=a7a12139a54c29083e6b73f6fde96c7f673482df;p=vlc diff --git a/src/video_output/snapshot.c b/src/video_output/snapshot.c index f6beb19a79..0f2c938175 100644 --- a/src/video_output/snapshot.c +++ b/src/video_output/snapshot.c @@ -27,7 +27,7 @@ #endif #include -#include +#include #include #include @@ -131,67 +131,7 @@ void vout_snapshot_Set(vout_snapshot_t *snap, /* */ char *vout_snapshot_GetDirectory(void) { - char *psz_path = NULL; -#if defined(__APPLE__) || defined(SYS_BEOS) - - if (asprintf(&psz_path, "%s/Desktop", - config_GetHomeDir()) == -1) - psz_path = NULL; - -#elif defined(WIN32) && !defined(UNDER_CE) - - /* Get the My Pictures folder path */ - char *p_mypicturesdir = NULL; - typedef HRESULT (WINAPI *SHGETFOLDERPATH)(HWND, int, HANDLE, DWORD, - LPWSTR); - #ifndef CSIDL_FLAG_CREATE - # define CSIDL_FLAG_CREATE 0x8000 - #endif - #ifndef CSIDL_MYPICTURES - # define CSIDL_MYPICTURES 0x27 - #endif - #ifndef SHGFP_TYPE_CURRENT - # define SHGFP_TYPE_CURRENT 0 - #endif - - HINSTANCE shfolder_dll; - SHGETFOLDERPATH SHGetFolderPath ; - - /* load the shfolder dll to retrieve SHGetFolderPath */ - if ((shfolder_dll = LoadLibrary(_T("SHFolder.dll"))) != NULL) - { - wchar_t wdir[PATH_MAX]; - SHGetFolderPath = (void *)GetProcAddress(shfolder_dll, - _T("SHGetFolderPathW")); - if ((SHGetFolderPath != NULL) - && SUCCEEDED (SHGetFolderPath (NULL, - CSIDL_MYPICTURES | CSIDL_FLAG_CREATE, - NULL, SHGFP_TYPE_CURRENT, - wdir))) - p_mypicturesdir = FromWide (wdir); - - FreeLibrary(shfolder_dll); - } - - if (p_mypicturesdir == NULL) - psz_path = strdup(config_GetHomeDir()); - else - psz_path = p_mypicturesdir; - -#else - - /* XXX: This saves in the data directory. Shouldn't we try saving - * to psz_homedir/Desktop or something nicer ? */ - char *psz_datadir = config_GetUserDataDir(); - if (psz_datadir) - { - if (asprintf(&psz_path, "%s", psz_datadir) == -1) - psz_path = NULL; - free(psz_datadir); - } - -#endif - return psz_path; + return config_GetUserDir(VLC_PICTURES_DIR); } /* */ int vout_snapshot_SaveImage(char **name, int *sequential, @@ -201,7 +141,7 @@ int vout_snapshot_SaveImage(char **name, int *sequential, { /* */ char *filename; - DIR *pathdir = utf8_opendir(cfg->path); + DIR *pathdir = vlc_opendir(cfg->path); if (pathdir != NULL) { /* The use specified a directory path */ closedir(pathdir); @@ -210,7 +150,9 @@ int vout_snapshot_SaveImage(char **name, int *sequential, char *prefix = NULL; if (cfg->prefix_fmt) prefix = str_format(object, cfg->prefix_fmt); - if (!prefix) { + if (prefix) + filename_sanitize(prefix); + else { prefix = strdup("vlcsnap-"); if (!prefix) goto error; @@ -225,7 +167,7 @@ int vout_snapshot_SaveImage(char **name, int *sequential, free(prefix); goto error; } - if (utf8_stat(filename, &st)) { + if (vlc_stat(filename, &st)) { *sequential = num; break; } @@ -268,7 +210,7 @@ int vout_snapshot_SaveImage(char **name, int *sequential, goto error; /* Save the snapshot */ - FILE *file = utf8_fopen(filename, "wb"); + FILE *file = vlc_fopen(filename, "wb"); if (!file) { msg_Err(object, "Failed to open '%s'", filename); free(filename);