Function FSItem

Summary

#include <include/fsitem.hpp>

(1) explicit FSItem(const wstring &path, const wstring &inArchivePath=L"")

(2) explicit FSItem(const wstring &dir, FSItemInfo data, const wstring &searchPath)

Function overload

Synopsis

#include <include/fsitem.hpp>

explicit FSItem(const wstring &path, const wstring &inArchivePath=L"")

Description

NOTES: 1) mPath contains the path to the file, including the filename. It can be relative or absolute, according to what the user passes as path parameter in the constructor. If it is a directory, it doesn't contain a trailing / or \ character, in order to use the method FindFirstFile without problems (as requested by that winapi function). 2) mSearchPath contains the search path in which the item was found (e.g. if FSIndexer is searching items in "foo/bar/", each FSItem created for the elements it found will have mSearchPath == "foo/bar"). As in mPath, mSearchPath does not contain trailing / or ! * 3) mInArchivePath is the path of the item in the archive. If not already given (i.e. the user doesn't want to custom the path of the file in the archive), the path in the archive is calculated form mPath and mSearchPath (see inArchivePath() method).

Source

Lines 42-57 in src/fsitem.cpp. Line 35 in include/fsitem.hpp.

FSItem::FSItem( const wstring& path, const wstring& inArchivePath )
    : mPath( path ), mFileData(), mSearchPath( L"" ), mInArchivePath( inArchivePath ) {
    bool is_dir = fsutil::isDirectory( mPath );
    if ( is_dir && !mPath.empty() ) {
        // The FSItem is a directory!
        // If the path ends with a / or a \, it's removed, since FindFirstFile doesn't want it!
        if ( mPath.back() == L'/' || mPath.back() == L'\\' ) {
            mPath.pop_back();
        }
    }
    HANDLE find_handle = FindFirstFile( mPath.c_str(), &mFileData );
    if ( find_handle == INVALID_HANDLE_VALUE ) {
        throw BitException( L"Invalid path '" + mPath + L"'!", GetLastError() );
    }
    FindClose( find_handle );
}

Synopsis

#include <include/fsitem.hpp>

explicit FSItem(const wstring &dir, FSItemInfo data, const wstring &searchPath)

Description

No description yet.

Source

Lines 59-68 in src/fsitem.cpp. Line 37 in include/fsitem.hpp.

FSItem::FSItem( const wstring& dir, FSItemInfo data, const wstring& search_path )
    : mPath( dir ), mFileData( data ), mSearchPath( search_path ) {
    /* Now mPath is the path without the filename, since dir is the path containing the file 'data'!
     * So we must add the filename! */
    if ( mPath.back() == L'/' || mPath.back() == L'\\' ) {
        mPath += name();
    } else {
        mPath += L"\\" + name();
    }
}





Add Discussion as Guest

Log in