Ejemplo n.º 1
0
int id3db_add( int db, char *path )
{
    struct id3ent id;
    id.vs = get_id3_tag(path);
    if(! id.vs ) return 1;

    id.path = strdup(path);
    m_put(db,&id);
    return 0;
}
Ejemplo n.º 2
0
// main scan loop
RETURNCODE mp3_scan_loop( bool bScanOnly ){

	DIR	*dir;
	struct dirent *file;
	struct stat finfo;

	if( (dir = opendir(".")) == NULL )
		return OPENDIR_ERROR;
	
	while( ( file = readdir( dir ) ) != NULL ){

		if( strcmp( ".", file->d_name ) != 0 && strcmp( "..", file->d_name ) != 0 ){

			stat( file->d_name, &finfo );						// get file info and check the type

			if( finfo.st_mode & S_IFREG ){						// is a file

				if( is_mp3_file( file->d_name ) ){				// if it's a MP3 file
					if( bScanOnly )
						Mp3Counter++;
					else
						get_id3_tag( file->d_name, finfo.st_size );
				}
			
			} else if( finfo.st_mode & S_IFDIR ){				// is a directory

				if( bRecursive ){
					chdir( file->d_name );
					strcat( szRelativePath, file->d_name );		// append directory name
					strcat( szRelativePath, "/" );				// and a '/'

					mp3_scan_loop( bScanOnly );
																// remove directory name
					szRelativePath[(strlen(szRelativePath) - strlen(file->d_name)) - 1] = '\0';
					chdir("..");
				}
			}
		} 														// .. and . check
	} 															// while loop end
	
	closedir( dir );											// close the dir handle
	
	return END_LOOP;
}