示例#1
0
S32 btmtk_goep_fs_findnext(void *ptr , bt_ftp_obj_info_struct *ftp_file_info) {
#ifdef BTMTK_GOEP_USE_WIN32_FS
    long *plong;
    U32 test_arrtibe;
    struct _wfinddata_t c_file;

    if( NULL == ptr || NULL == ftp_file_info) {
        return EXT_FS_ERR;
    }

    plong = ptr;
    GOEP_MEMSET( (U8 *) ftp_file_info, 0, sizeof(bt_ftp_obj_info_struct) );
    if( 0 == _wfindnext( (long)*plong, &c_file ) ) {
        //ext_asc_str_n_to_ucs2_str( ftp_file_info->file_name, c_file.name, 260/2);
        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);
        // ok. find the next
        test_arrtibe = (_A_SUBDIR & c_file.attrib);
        ftp_file_info->file_size = c_file.size;

        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
    FS_DOSDirEntry dir_entry;
    bt_ftp_find_struct *findstruct;
    U8 filename[ BTMTK_EP_MAX_FILENAME_LEN ];
    U8 ucfilename[ BTMTK_EP_MAX_FILENAME_LEN ];

    if( NULL != ptr ) {
        findstruct = (bt_ftp_find_struct *) ptr;
        if( 0 <= FS_FindNext( (FS_HANDLE) findstruct->hFile , &dir_entry, (U16 *) filename, sizeof(filename) ) ) {
            static_convert_DirEntry_to_file_info( &dir_entry, ftp_file_info , filename);

            memset( ucfilename, 0, sizeof( ucfilename) );
            ext_chset_ucs2_to_utf8_string( (U8 *)ucfilename, sizeof(ucfilename) - 1, (U8 *)filename );
            GOEP_Report("[ftp][fs] findnext file:(%s)", ucfilename);
            return EXT_FS_OK;
        }
    }
#endif

#ifdef BTMTK_ON_LINUX

    return static_linux_fill_file_info(ftp_file_info);

#endif

    return EXT_FS_ERR;
}
示例#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
文件: 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;
}
示例#4
0
文件: files.c 项目: Oppen/Wolf3DRedux
/**
 * \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;
	char		path[ MAX_OSPATH ];
	pack_t		*pak;
	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;
		}
	}
}
示例#5
0
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
/*
-----------------------------------------------------------------------------
 Function: FS_FindFirstFile() -Searches a directory for a file. 
 
 Parameters: path -[in] Pointer to a NUL-terminated string that specifies 
                      a valid directory or path and file name. 
			musthave -[in] File or directory must have these attributes.
			canthave- [in] File or directory can not have these attributes.
 
 Returns: On success string of file name or directory, otherwise NULL.
 
 Notes: 
-----------------------------------------------------------------------------
*/
PUBLIC char *FS_FindFirst( const char *path, W32 musthave, W32 canthave )
{
    WIN32_FIND_DATA FindFileData;

	if( FindHandle )
	{
		printf( "FS_FindFirst without close\n" );

		return NULL;
	}
  
	FS_FilePath( path, findbase );

	FindHandle = FindFirstFile( path, &FindFileData );

	if( FindHandle == INVALID_HANDLE_VALUE )
	{
		return NULL;
	}



	if( CompareAttributes( FindFileData.dwFileAttributes, musthave, canthave ) )
	{
		if( ! *findbase )
		{
			cs_strlcpy( findpath, FindFileData.cFileName, sizeof( findpath ) );
		}
		else
		{
			cs_snprintf( findpath, sizeof( findpath ), "%s/%s", findbase, FindFileData.cFileName );
		}

		return findpath;
	}
		
   
    return FS_FindNext( musthave, canthave );
}
示例#7
0
int main(void)
	{
	//*******************************************************************
	Init();
	TMRInit(2);		// Initialize Timer interface with Priority=2
	BLIInit();		// Initialize Signal interface
	//*******************************************************************
	//_T1IE 	= 0; 	// Temporarily disable Timer1 interrupt
	//*******************************************************************
	LogInit();			// Initialize Data Logger
	//*******************************************************************
	uint	i;
	char		RData[30];
	char		CData[30];

	for (i = 0; i < 30; i++)
		{
		RData[i] = CData[i] = 0;
		}

	char*		pFN		= "log1.txt";
	void*		pWData	= &"01 02 03 04 05 06 07 08 09";
	//-------------------------------------------------------------------
	
	CETYPE			RC;
	uint			ReadCnt;
	
	FSFILE			File;
	SEARCH_STATE	Search;
	//*******************************************************************
	BLISignalON();
	//*******************************************************************
	
	// Search for every entry in the Root
	RC = FS_FindFirst(	"*", ATTR_NONE,  ATTR_NONE, &Search, &File);	
	while (CE_GOOD == RC)
		{
		RC = FS_FindNext(&Search, &File);
		}

	// Search only for files
	RC = FS_FindFirst(	"*", ATTR_NONE,  ATTR_DIRECTORY, &Search, &File);	
	while (CE_GOOD == RC)
		{
		RC = FS_FindNext(&Search, &File);
		}

	// Search only for directories
Deeper:
	RC = FS_FindFirst(	"*", ATTR_DIRECTORY,  ATTR_NONE, &Search, &File);	
	if (CE_GOOD == RC)
		{
		RC = FS_chDir(&File);
		if (CE_GOOD == RC)
			goto Deeper;
		}
		
Higher:
	RC = FS_GetCWD(&File);
	RC = CE_GOOD;
	RC = FS_chDirUp();
	if (CE_GOOD == RC)
		goto Higher;
		
	//*******************************************************************


	//------------------------------
	// Create (Open) file for Writing and Reading 
	//------------------------------
	RC = FS_CreateFile(pFN, FS_CREATE_NEW, &File);
	while ( RC != CE_GOOD );
	//------------------------------
	// Write sample string to file
	//------------------------------
   	RC = FS_Write (&File, pWData, 26 );
	while (CE_GOOD != RC);
	//------------------------------
	// Check position in the file
	//------------------------------
   	i = FS_GetPosition (&File);
	while (i != 26);
	//------------------------------
	// Seek to start
	//------------------------------
   	FS_SeekStart(&File);
	//------------------------------
	// Reed from start
	//------------------------------
   	RC = FS_Read (&File, RData, 26, &ReadCnt);
	while (CE_GOOD != RC);
	//------------------------------
	// Close the file - save changes
	//------------------------------
	RC = FS_Flush(&File);
   	while ( RC != CE_GOOD );
	//------------------------------

	//------------------------------
	// Open file for Reading 
	//------------------------------
	RC = FS_CreateFile(pFN, FS_READ_ONLY, &File);
	while ( RC != CE_GOOD );
	//------------------------------
	// Reed from start
	//------------------------------
   	RC = FS_Read (&File, CData, 26, &ReadCnt);
	while (CE_GOOD != RC);
	//------------------------------
	// Close the file - save changes
	//------------------------------
	RC = FS_Flush(&File);
   	while ( RC != CE_GOOD );
	//------------------------------
	i = 1 + i;

	//*******************************************************************
	BLISignalOFF();
	//------------------------------
	while(1);
	return 0;
	}