コード例 #1
0
S32 btmtk_goep_fs_findend(void *ptr) {
    bt_ftp_find_struct *pfind;
    pfind = (bt_ftp_find_struct *) ptr;

#if defined(BTMTK_ON_WISE)
    if( NULL != pfind ) {
        FS_FindClose( (FS_HANDLE) pfind->hFile);
        pfind->hFile = 0;
        free_ctrl_buffer( pfind );
    }
#endif

#ifdef BTMTK_GOEP_USE_WIN32_FS
    _findclose(pfind->hFile);
    _wchdir( (const U16 *) g_oldcwd );
    if( NULL !=  ptr )
        free( ptr );
#endif

#ifdef BTMTK_ON_LINUX
    closedir(g_opened_dir);
#endif

    return EXT_FS_OK;
}
コード例 #2
0
/*****************************************************************************
 * FUNCTION
 *  applib_file_delete_folder
 * DESCRIPTION
 *  This function is used to remove one folder.
 * PARAMETERS
 *  foldername      [IN]        The foldername
 * RETURNS
 *  void
 *****************************************************************************/
kal_bool applib_file_delete_folder(kal_wchar *foldername)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    int h = -1; /* save temp. file handle for find */
    FS_DOSDirEntry info;
    kal_wchar path[200];
    kal_wchar filename[100];
    kal_wchar wildcard[6];

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (foldername == NULL)
    {
        return KAL_FALSE;
    }
    else if (app_ucs2_strlen((kal_int8*) foldername) > 97)
    {
        return KAL_FALSE;
    }
    else
    {

        kal_mem_set(path, 0, 400);
        app_ucs2_strcpy((kal_int8*) path, (kal_int8*) foldername);
        kal_wsprintf(wildcard, "\\*");
        app_ucs2_strcat((kal_int8*) path, (kal_int8*) wildcard);

        h = FS_FindFirst(path, 0, 0, &info, filename, 200);
        if (h < 0)
        {
            return KAL_FALSE;
        }
        do
        {
            /* filter out folder results */
            if (!(info.Attributes & FS_ATTR_DIR))
            {
                kal_mem_set(path, 0, 400);
                app_ucs2_strcpy((kal_int8*) path, (kal_int8*) foldername);
                kal_wsprintf(wildcard, "\\");
                app_ucs2_strcat((kal_int8*) path, (kal_int8*) wildcard);
                app_ucs2_strcat((kal_int8*) path, (kal_int8*) filename);
                FS_Delete(path);
                kal_mem_set(filename, 0x00, 200);
            }
        } while (FS_FindNext(h, &info, filename, 200) == FS_NO_ERROR);
        FS_FindClose(h);
    }
    return KAL_TRUE;
}
コード例 #3
0
ファイル: IP_FS_FS.c プロジェクト: agb861/ddd
/*********************************************************************
*
*       _ForEachDirEntry
*/
static void _ForEachDirEntry (void * pContext, const char * sDir, void (*pf) (void * pContext, void * pFileEntry)) {
  FS_FIND_DATA fd;
  char acDirname[MAX_PATH];
  char acFilename[MAX_PATH];

  _InitIfRequired();         // Perform automatic initialisation so that explicit call to FS_Init is not required
  _ConvertPath(sDir, acDirname, sizeof(acDirname));
  if (FS_FindFirstFile(&fd, acDirname, acFilename, sizeof(acFilename)) == 0) {
    do {
      pf(pContext, &fd);
    } while (FS_FindNextFile (&fd));
  }
  FS_FindClose(&fd);
}
コード例 #4
0
ファイル: pak.c プロジェクト: Oppen/WolfExtractor
/**
 * \brief Add directory to zip file.
 * \param[in] path Directory path that will be added to zip file.
 * \param[in,out] f File stream to write compressed files to.
 * \return On success true, otherwise false.
 */
PRIVATE wtBoolean Pak_addDirectoryToZipFile( const char *path, FILE *f )
{
	char temp[ 256 ];
	char *ptr;
	zipHead_t *newZipNode = NULL;


	wt_strlcpy( temp, path, sizeof( temp ) );

	if( strstr( temp, "*" ) == NULL )
	{
		wt_strlcat( temp, "/*", sizeof( temp ) );
	}

	// Look for files
	ptr = FS_FindFirst( temp );

	do {
		wt_snprintf( temp, sizeof( temp ), "%s/%s", path, ptr );

		if ( temp[strlen(temp)-1] == '.' )
		{
			continue;
		}

		if( ! FS_CompareFileAttributes( temp, 0, FA_DIR ) )
		{
			continue;
		}

		newZipNode = Pak_WriteLocalFileChunk( temp, f );
		if( newZipNode == NULL )
		{
			continue;
		}

		// add new zipHead_t to chain
		zipChainLast = linkList_addList( zipChainLast, newZipNode );
	} while( (ptr = FS_FindNext()) != NULL );

	FS_FindClose();

	return true;
}
コード例 #5
0
ファイル: FileSystemDummy.c プロジェクト: jprothwell/sc-fix
S32 fmt_delete_by_filter_hdlr(U8 *path, FMGR_FILTER *filter_mask)
{
	FS_HANDLE		handle;
	FS_DOSDirEntry	file_info;
	U8 		file_name[40];
	S32		fs_ret;
	U8		i;

	pfnUnicodeStrcat((PS8)path, (PS8)L"*.*");
	handle = FS_FindFirst((WCHAR *)path, 0, 0, &file_info, (WCHAR *)file_name, 40);
	if (handle < 0)
		return FS_NO_ERROR;

	mmi_fmgr_remove_last_dir((char*)path);
	
	fs_ret = FS_SetCurrentDir((WCHAR *)path);
	if (fs_ret < 0)
		return fs_ret;

	while (1)
	{
		for(i = 0 ; i < FMGR_MAX_FILTER_COUNT ; i++)
		{
			if( FMGR_FILTER_IS_SET(filter_mask, fmgr_filter[i].type) )
			{
				if (strncmp((char *)file_info.Extension, (char *)fmgr_filter[i].ext, 3) == 0)
				{
					fs_ret = FS_Delete((WCHAR *)file_name);
					if (fs_ret < 0)
						return fs_ret;
					break;
				}
			}
		}

		fs_ret = FS_FindNext (handle, &file_info, (WCHAR *)file_name, 40);
		if (fs_ret < 0)
			break;
	}

	FS_FindClose (handle);
	return FS_NO_ERROR;
}
コード例 #6
0
/**
 * \brief Execute autoexec script
 */
PUBLIC void FS_ExecAutoexec( void )
{
	char *dir;
	char name[ MAX_GAMEPATH ];

	dir = Cvar_VariableString( "gamedir" );
	if( *dir )
	{
		com_snprintf( name, sizeof( name ), "%s%c%s%cautoexec.cfg", fs_basedir->string, PATH_SEP, dir, PATH_SEP ); 
	}
	else
	{
		com_snprintf(name, sizeof(name), "%s%c%s%cautoexec.cfg", fs_basedir->string, PATH_SEP, BASE_DIRECTORY, PATH_SEP); 
	}

	if( FS_FindFirst( name, 0, FA_DIR | FA_HIDDEN | FA_SYSTEM ) )
	{
		Cbuf_AddText( "exec autoexec.cfg\n" );
	}

	FS_FindClose();
}
コード例 #7
0
/**
 * \brief Add directory to search path.
 * \param[in] dir Game directory path.
 * \note Sets fs_gamedir, adds the directory to the head of the path, then loads and adds *.pak then *.zip files.
 */
PRIVATE void FS_AddGameDirectory( const char *dir )
{
	searchpath_t	*search;
	pack_t			*pak;
	char			path[ MAX_OSPATH ];
	char			*pakfile;

	com_strlcpy( fs_gamedir, dir, sizeof( fs_gamedir ) );

	//
	// add the directory to the search path
	//
	search = (searchpath_t *) Z_Malloc( sizeof( searchpath_t ) );
	com_strlcpy( search->filename, dir, sizeof( search->filename ) );
	search->next = fs_searchpaths;
	fs_searchpaths = search;

	//
	// add any pak files 
	//
	com_snprintf( path, sizeof( path ), "%s%c*.pak", fs_gamedir, PATH_SEP );
	
	pakfile = FS_FindFirst( path, 0, 0 );
	if( pakfile )
	{		
		pak = FS_LoadZipFile( pakfile );
		if( pak )
		{
			search = (searchpath_t *) Z_Malloc( sizeof( searchpath_t ) );
			search->pack = pak;
			search->next = fs_searchpaths;
			fs_searchpaths = search;
		}
		
		
		while( (pakfile = FS_FindNext( 0, 0 )) != NULL )
		{
			pak = FS_LoadZipFile( pakfile );
			if( ! pak )
			{
				continue;
			}
			search = Z_Malloc( sizeof( searchpath_t ) );
			search->pack = pak;
			search->next = fs_searchpaths;
			fs_searchpaths = search;
		}
	}

	FS_FindClose();

	//
	// add any zip files 
	//
	com_snprintf( path, sizeof( path ), "%s%c*.zip", fs_gamedir, PATH_SEP );
	
	pakfile = FS_FindFirst( path, 0, 0 );
	if( pakfile )
	{		
		pak = FS_LoadZipFile( pakfile );
		if( pak )
		{
			search = (searchpath_t *) Z_Malloc( sizeof( searchpath_t ) );
			search->pack = pak;
			search->next = fs_searchpaths;
			fs_searchpaths = search;
		}
		
		
		while( (pakfile = FS_FindNext( 0, 0 )) != NULL )
		{
			pak = FS_LoadZipFile( pakfile );
			if( ! pak )
			{
				continue;
			}
			search = Z_Malloc( sizeof( searchpath_t ) );
			search->pack = pak;
			search->next = fs_searchpaths;
			fs_searchpaths = search;
		}
	}

	FS_FindClose();

}
コード例 #8
0
S32 btmtk_goep_fs_findfirst(U8 *ucFolderPath, bt_ftp_find_struct **findstruct, bt_ftp_obj_info_struct *ftp_file_info) {
#ifdef BTMTK_GOEP_USE_WIN32_FS
    char sdir[256];
    char filter[64];
    U32 test_arrtibe;
    struct _wfinddata_t c_file;
    long hFile;
    bt_ftp_find_struct *pfind;

    GOEP_MEMSET((U8 *)ftp_file_info, 0, sizeof(bt_ftp_obj_info_struct) );

    ext_ucs2_str_n_to_asc_str(sdir, ucFolderPath, sizeof(sdir));

    // keep the previous folder path
    g_oldcwd[0] = 0;
    if ( NULL == _wgetcwd( (U16 *)g_oldcwd, sizeof(g_oldcwd)/2 ) ) {
        /// cannot keep the current folder
        GOEP_Report("[FS][ERR] fail to get cwd bufsize:(%d) err:%d!", sizeof(g_oldcwd)/2, GetLastError());
        return EXT_FS_ERR;
    }

    printf( "[fs] getcwd is '%s'\n", g_oldcwd);
    printf( "[fs] fs findfirst '%s' \n", sdir );
    _wchdir( (U16 *) ucFolderPath );


    ext_strncpy (filter, "*.*", 64);
    hFile = _wfindfirst(L"*.*", &c_file);

    if( -1 == hFile ) {
        return EXT_FS_ERR;
    } else {
        //plong = (long * )malloc(sizeof(long));
        pfind = (bt_ftp_find_struct *) malloc( sizeof(bt_ftp_find_struct) );
        *findstruct = pfind;

        if( *findstruct == NULL ) {
            return EXT_FS_ERR;
        }
        ((bt_ftp_find_struct *)*findstruct)->hFile = hFile;

        ext_ucs2ncpy( (S8 *) ftp_file_info->file_name, (const S8 *) c_file.name, sizeof(ftp_file_info->file_name)/2);
        update_win32_file_time(ftp_file_info);
        test_arrtibe = (_A_SUBDIR & c_file.attrib);
        if( _A_SUBDIR == test_arrtibe) {
            ftp_file_info->isFile = FALSE;
        } else {
            ftp_file_info->isFile = TRUE;
        }
        return EXT_FS_OK;
    }
#endif

#ifdef BTMTK_ON_WISE
    U8 *filter;
    S32 hFile;
    S32 len;
    bt_ftp_find_struct *pfind;
    FS_DOSDirEntry dir_entry;
    U8 filename[ BTMTK_EP_MAX_FILENAME_LEN ]; /// output

    //ext_ucs2ncpy (filter, (const U8 *)L"\\*.*", sizeof(filter)/2);
    len = ext_ucs2strlen((const S8*)ucFolderPath)*2 + 10;
    filter = (U8 *) get_ctrl_buffer( len ); // plus L"\\*.*"
    if( NULL == filter ) {
        return EXT_FS_ERR;
    }
    btmtk_os_memset( filter, 0, len);
    ext_ucs2ncpy( (U8 *) filter,  (const U8 *) ucFolderPath , len-2);
    ext_ucs2ncat( (U8 *) filter, (const U8 *) L"\\*.*", len-2);

    ext_ucs2ncpy((S8 *)filename, (const U8 *)L"", (sizeof(filename)/2)-1);

    hFile = (S32) FS_FindFirst(
                (const WCHAR*)filter,
                0,
                0,
                &dir_entry,
                (U16*) filename,
                sizeof(filename) );
    if( NULL == filter ) {
        free_ctrl_buffer(filter);
        filter = NULL;
    }
    if ( hFile >= 0) {
        GOEP_MEMSET((U8 *)ftp_file_info, 0, sizeof(bt_ftp_obj_info_struct) );
        pfind = (bt_ftp_find_struct *) get_ctrl_buffer( sizeof(bt_ftp_find_struct) );
        *findstruct = pfind;
        if( *findstruct == NULL ) {
            FS_FindClose( (FS_HANDLE) hFile );
            return EXT_FS_ERR;
        }
        ((bt_ftp_find_struct *)*findstruct)->hFile = hFile;

        static_convert_DirEntry_to_file_info( &dir_entry, ftp_file_info , filename);

        return EXT_FS_OK;
    } else {
        return EXT_FS_ERR;
    }

#endif

#ifdef BTMTK_ON_LINUX

    int ret;
    int err_num;

    bt_ext_log("[GOEP_FS] btmtk_goep_fs_findfirst(): Linux Version.");

    ext_chset_ucs2_to_utf8_string((U8 *) g_folder_path, sizeof(g_folder_path)-1, ucFolderPath);
    // strncpy(g_folder_path, ucFolderPath, sizeof(g_folder_path));
    bt_ext_log("[GOEP_FS] g_folder_path: %s", g_folder_path);

    g_opened_dir = opendir( g_folder_path);
    if (g_opened_dir == NULL) {
        err_num = errno;
        bt_ext_err("[FS_ERR] opendir() failed. %s", (char*) strerror(err_num));
        return EXT_FS_ERR;
    }

    return static_linux_fill_file_info(ftp_file_info);

#endif

    return EXT_FS_ERR;
}