public CFolderContent listFolder( CPath path )
            throws CStorageException
    {
        JSONArray array = listObjectsWithinFolder( path, "/" );
        CFile file;
        if ( array == null || array.length() == 0 ) {
            // List is empty ; can be caused by a really empty folder,
            // a non existing folder, or a blob
            // Distinguish the different cases :
            file = getFile( path );
            if ( file == null ) { // Nothing at that path
                return null;
            }
            if ( file.isBlob() ) { // It is a blob : error !
                throw new CInvalidFileTypeException( path, false );
            }
            return new CFolderContent( Collections.EMPTY_MAP );
        }

        Map<CPath, CFile> ret = new HashMap<CPath, CFile>();

        boolean detailed;
        JSONObject obj;
        for ( int i = 0; i < array.length(); i++ ) {
            obj = array.getJSONObject( i );
            if ( obj.has( "subdir" ) ) {
                // indicates a non empty sub directory
                // There are two cases here : provider uses directory-markers, or not.
                // - if yes, another entry should exist in json with more detailed informations.
                // - if not, this will be the only entry that indicates a sub folder,
                //   so we keep this file, but we'll memorize it only if it is not already present
                //   in returned value.
                file = new CFolder( new CPath( obj.getString( "subdir" ) ) );
                detailed = false;

            } else {
                detailed = true;
                if ( !CONTENT_TYPE_DIRECTORY.equals( obj.getString( "content_type" ) ) ) {
                    file = new CBlob( new CPath( obj.getString( "name" ) ),
                                      obj.getLong( "bytes" ),
                                      obj.getString( "content_type" ),
                                      parseLastModified( obj ),
                                      null ); // we do not have this detailed information
                } else {
                    file = new CFolder( new CPath( obj.getString( "name" ) ),
                                        parseLastModified( obj ),
                                        null ); // we do not have this detailed information
                }
            }

            if ( detailed || !ret.containsKey( path ) ) {
                // If we got a detailed file, we always store it
                // If we got only rough description, we keep it only if no detailed info already exists
                ret.put( file.getPath(), file );
            }
        }
        return new CFolderContent( ret );
    }
public CFolderContent listFolder ( CPath path ) throws CStorageException { JSONArray array = listObjectsWithinFolder ( path , "/" ) ; CFile file ; if ( array == null || array . length ( ) == 0 ) { file = getFile ( path ) ; if ( file == null ) { return null ; } if ( file . isBlob ( ) ) { throw new CInvalidFileTypeException ( path , false ) ; } return new CFolderContent ( Collections . EMPTY_MAP ) ; } Map < CPath , CFile > ret = new HashMap < CPath , CFile > ( ) ; boolean detailed ; JSONObject obj ; for ( int i = 0 ; i < array . length ( ) ; i ++ ) { obj = array . getJSONObject ( i ) ; if ( obj . has ( "subdir" ) ) { file = new CFolder ( new CPath ( obj . getString ( "subdir" ) ) ) ; detailed = false ; } else { detailed = true ; if ( ! CONTENT_TYPE_DIRECTORY . equals ( obj . getString ( "content_type" ) ) ) { file = new CBlob ( new CPath ( obj . getString ( "name" ) ) , obj . getLong ( "bytes" ) , obj . getString ( "content_type" ) , parseLastModified ( obj ) , null ) ; } else { file = new CFolder ( new CPath ( obj . getString ( "name" ) ) , parseLastModified ( obj ) , null ) ; } } if ( detailed || ! ret . containsKey ( path ) ) { ret . put ( file . getPath ( ) , file ) ; } } return new CFolderContent ( ret ) ; }
Return map of CFile in given folder. Key is file CPath

@param path the CFolder object or CPath to be listed
@return