Changeset 45915c74f0baaaed6527dc888f3e4263fb50e7d7
- Timestamp:
- 21/08/07 20:02:43
(1 year ago)
- Author:
- Rémi Denis-Courmont <rem@videolan.org>
- git-committer:
- Rémi Denis-Courmont <rem@videolan.org> 1187719363 +0000
- git-parent:
[9b84d144a7c957beab0f5ba38fd48b481984014e]
- git-author:
- Rémi Denis-Courmont <rem@videolan.org> 1187719363 +0000
- Message:
Fix utf8_readdir usage
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r9e595c9 |
r45915c7 |
|
| 150 | 150 | msg_Dbg( p_intf, "dir=%s", psz_dir ); |
|---|
| 151 | 151 | |
|---|
| 152 | | sprintf( dir, "%s%c.access", psz_dir, sep ); |
|---|
| | 152 | snprintf( dir, sizeof( dir ), "%s%c.access", psz_dir, sep ); |
|---|
| 153 | 153 | if( ( file = utf8_fopen( dir, "r" ) ) != NULL ) |
|---|
| 154 | 154 | { |
|---|
| … | … | |
| 184 | 184 | } |
|---|
| 185 | 185 | |
|---|
| 186 | | sprintf( dir, "%s%c.hosts", psz_dir, sep ); |
|---|
| | 186 | snprintf( dir, sizeof( dir ), "%s%c.hosts", psz_dir, sep ); |
|---|
| 187 | 187 | p_acl = ACL_Create( p_intf, VLC_FALSE ); |
|---|
| 188 | 188 | if( ACL_LoadFile( p_acl, dir ) ) |
|---|
| … | … | |
| 194 | 194 | for( ;; ) |
|---|
| 195 | 195 | { |
|---|
| 196 | | const char *psz_filename; |
|---|
| | 196 | char *psz_filename; |
|---|
| 197 | 197 | /* parse psz_src dir */ |
|---|
| 198 | 198 | if( ( psz_filename = utf8_readdir( p_dir ) ) == NULL ) |
|---|
| … | … | |
| 203 | 203 | if( ( psz_filename[0] == '.' ) |
|---|
| 204 | 204 | || ( i_dirlen + strlen( psz_filename ) > MAX_DIR_SIZE ) ) |
|---|
| | 205 | { |
|---|
| | 206 | free( psz_filename ); |
|---|
| 205 | 207 | continue; |
|---|
| 206 | | |
|---|
| 207 | | sprintf( dir, "%s%c%s", psz_dir, sep, psz_filename ); |
|---|
| 208 | | free( (char*) psz_filename ); |
|---|
| | 208 | } |
|---|
| | 209 | |
|---|
| | 210 | snprintf( dir, sizeof( dir ), "%s%c%s", psz_dir, sep, psz_filename ); |
|---|
| | 211 | free( psz_filename ); |
|---|
| 209 | 212 | |
|---|
| 210 | 213 | if( E_(ParseDirectory)( p_intf, psz_root, dir ) ) |
|---|
| r81c5ac2 |
r45915c7 |
|
| 1533 | 1533 | if (!s_filename.compare(p_demux->psz_path)) |
|---|
| 1534 | 1534 | #endif |
|---|
| | 1535 | { |
|---|
| | 1536 | free (psz_file); |
|---|
| 1535 | 1537 | continue; // don't reuse the original opened file |
|---|
| | 1538 | } |
|---|
| 1536 | 1539 | |
|---|
| 1537 | 1540 | #if defined(__GNUC__) && (__GNUC__ < 3) |
|---|
| r9e595c9 |
r45915c7 |
|
| 28 | 28 | * Preamble |
|---|
| 29 | 29 | *****************************************************************************/ |
|---|
| | 30 | #include <vlc/vlc.h> |
|---|
| | 31 | |
|---|
| 30 | 32 | #include <errno.h> /* ENOMEM */ |
|---|
| 31 | 33 | #include <time.h> |
|---|
| … | … | |
| 33 | 35 | #include <curses.h> |
|---|
| 34 | 36 | |
|---|
| 35 | | #include <vlc/vlc.h> |
|---|
| 36 | 37 | #include <vlc_interface.h> |
|---|
| 37 | 38 | #include <vlc_vout.h> |
|---|
| … | … | |
| 1928 | 1929 | p_sys->i_dir_entries = 0; |
|---|
| 1929 | 1930 | |
|---|
| 1930 | | /* get the first directory entry */ |
|---|
| 1931 | | psz_entry = utf8_readdir( p_current_dir ); |
|---|
| 1932 | | |
|---|
| 1933 | 1931 | /* while we still have entries in the directory */ |
|---|
| 1934 | | while( psz_entry != NULL ) |
|---|
| | 1932 | while( ( psz_entry = utf8_readdir( p_current_dir ) ) != NULL ) |
|---|
| 1935 | 1933 | { |
|---|
| 1936 | 1934 | #if defined( S_ISDIR ) |
|---|
| … | … | |
| 1947 | 1945 | { |
|---|
| 1948 | 1946 | free( psz_entry ); |
|---|
| 1949 | | psz_entry = utf8_readdir( p_current_dir ); |
|---|
| 1950 | 1947 | continue; |
|---|
| 1951 | 1948 | } |
|---|
| … | … | |
| 1956 | 1953 | if( !( p_dir_entry = malloc( sizeof( struct dir_entry_t) ) ) ) |
|---|
| 1957 | 1954 | { |
|---|
| 1958 | | free( psz_uri); |
|---|
| 1959 | | return; |
|---|
| | 1955 | free( psz_uri ); |
|---|
| | 1956 | free( psz_entry ); |
|---|
| | 1957 | continue; |
|---|
| 1960 | 1958 | } |
|---|
| 1961 | 1959 | |
|---|
| 1962 | 1960 | #if defined( S_ISDIR ) |
|---|
| 1963 | | utf8_stat( psz_uri, &stat_data ); |
|---|
| 1964 | | if( S_ISDIR(stat_data.st_mode) ) |
|---|
| | 1961 | if( !utf8_stat( psz_uri, &stat_data ) |
|---|
| | 1962 | && S_ISDIR(stat_data.st_mode) ) |
|---|
| 1965 | 1963 | /*#elif defined( DT_DIR ) |
|---|
| 1966 | 1964 | if( p_dir_content->d_type & DT_DIR )*/ |
|---|
| … | … | |
| 1984 | 1982 | free( psz_uri ); |
|---|
| 1985 | 1983 | free( psz_entry ); |
|---|
| 1986 | | /* Read next entry */ |
|---|
| 1987 | | psz_entry = utf8_readdir( p_current_dir ); |
|---|
| 1988 | 1984 | } |
|---|
| 1989 | 1985 | |
|---|
| r1cffa56 |
r45915c7 |
|
| 417 | 417 | * @param dir The directory that is being read |
|---|
| 418 | 418 | * |
|---|
| 419 | | * @return a UTF-8 string of the directory entry. Use LocaleFree() to free this memory |
|---|
| | 419 | * @return a UTF-8 string of the directory entry. Use free() to free this memory. |
|---|
| 420 | 420 | */ |
|---|
| 421 | 421 | char *utf8_readdir( DIR *dir ) |
|---|