pub fn open(ledger_path: &str, create: bool) -> io::Result<Self> {
        let ledger_path = Path::new(&ledger_path);

        if create {
            let _ignored = remove_dir_all(ledger_path);
            create_dir_all(ledger_path)?;
        }

        let index = OpenOptions::new()
            .create(create)
            .append(true)
            .open(ledger_path.join(LEDGER_INDEX_FILE))?;

        if log_enabled!(Trace) {
            let len = index.metadata()?.len();
            trace!("LedgerWriter::new: index fp:{}", len);
        }
        let index = BufWriter::new(index);

        let data = OpenOptions::new()
            .create(create)
            .append(true)
            .open(ledger_path.join(LEDGER_DATA_FILE))?;

        if log_enabled!(Trace) {
            let len = data.metadata()?.len();
            trace!("LedgerWriter::new: data fp:{}", len);
        }
        let data = BufWriter::new(data);

        Ok(LedgerWriter { index, data })
    }
// opens or creates a LedgerWriter in ledger_path directory
opens or creates a LedgerWriter in ledger_path directory
opens or creates a LedgerWriter in ledger_path directory
pub fn open(ledger_path: &str, create: bool) -> io::Result<Self> {
        let ledger_path = Path::new(&ledger_path);
        if create {
            let _ignored = remove_dir_all(ledger_path);
            create_dir_all(ledger_path)?;
        }
        let index = OpenOptions::new()
            .create(create)
            .append(true)
            .open(ledger_path.join(LEDGER_INDEX_FILE))?;
        if log_enabled!(Trace) {
            let len = index.metadata()?.len();
            trace!("LedgerWriter::new: index fp:{}", len);
        }
        let index = BufWriter::new(index);
        let data = OpenOptions::new()
            .create(create)
            .append(true)
            .open(ledger_path.join(LEDGER_DATA_FILE))?;
        if log_enabled!(Trace) {
            let len = data.metadata()?.len();
            trace!("LedgerWriter::new: data fp:{}", len);
        }
        let data = BufWriter::new(data);
        Ok(LedgerWriter { index, data })
    }
pub fn open ( ledger_path : & str , create : bool ) -> io :: Result < Self > { let ledger_path = Path :: new ( & ledger_path ) ; if create { let _ignored = remove_dir_all ( ledger_path ) ; create_dir_all ( ledger_path ) ? ; } let index = OpenOptions :: new ( ) . create ( create ) . append ( true ) . open ( ledger_path . join ( LEDGER_INDEX_FILE ) ) ? ; if log_enabled ! ( Trace ) { let len = index . metadata ( ) ? . len ( ) ; trace ! ( " " len ) ; } let index = BufWriter :: new ( index ) ; let data = OpenOptions :: new ( ) . create ( create ) . append ( true ) . open ( ledger_path . join ( LEDGER_DATA_FILE ) ) ? ; if log_enabled ! ( Trace ) { let len = data . metadata ( ) ? . len ( ) ; trace ! ( " " len ) ; } let data = BufWriter :: new ( data ) ; Ok ( LedgerWriter { index , data } ) }
opens or creates a LedgerWriter in ledger_path directory
opens or creates a LedgerWriter in ledger_path directory
ledger_path
&str
create
bool
ledger_path
&str
create
bool