fn _inner(dir: &Path) -> std::io::Result<bool> {
            let path = dir.join("status.txt");
            let mut buf = vec![];
            if !dir.is_dir() {
                Ok(false)
            } else if path.exists() {
                // already exist and check status
                {
                    let mut fs = File::open(&path)?;
                    fs.read_to_end(&mut buf)?;
                }
                if buf.starts_with(b"released") {
                    let mut fs = File::create(&path)?;
                    fs.seek(SeekFrom::Start(0))?;
                    fs.write(b"working")?;
                    Ok(true)
                } else {
                    // need recreate
                    Ok(false)
                }
            } else {
                // write working flag
                let mut fs = File::create(&path)?;
                fs.write(b"working")?;
                Ok(true)
            }
        }
// check graceful exit
// status flag (working or release)
check graceful exit
status flag (working or release)
check graceful exit status flag ( working or release )
fn _inner(dir: &Path) -> std::io::Result<bool> {
            let path = dir.join("status.txt");
            let mut buf = vec![];
            if !dir.is_dir() {
                Ok(false)
            } else if path.exists() {
                // already exist and check status
                {
                    let mut fs = File::open(&path)?;
                    fs.read_to_end(&mut buf)?;
                }
                if buf.starts_with(b"released") {
                    let mut fs = File::create(&path)?;
                    fs.seek(SeekFrom::Start(0))?;
                    fs.write(b"working")?;
                    Ok(true)
                } else {
                    // need recreate
                    Ok(false)
                }
            } else {
                // write working flag
                let mut fs = File::create(&path)?;
                fs.write(b"working")?;
                Ok(true)
            }
        }
fn _inner ( dir : & Path ) -> std :: io :: Result < bool > { let path = dir . join ( " " ) ; let mut buf = vec ! [ ] ; if ! dir . is_dir ( ) { Ok ( false ) } else if path . exists ( ) { // already exist and check status { let mut fs = File :: open ( & path ) ? ; fs . read_to_end ( & mut buf ) ? ; } if buf . starts_with ( b" " ) { let mut fs = File :: create ( & path ) ? ; fs . seek ( SeekFrom :: Start ( 0 ) ) ? ; fs . write ( b" " ) ? ; Ok ( true ) } else { // need recreate Ok ( false ) } } else { // write working flag let mut fs = File :: create ( & path ) ? ; fs . write ( b" " ) ? ; Ok ( true ) } }
check graceful exit
status flag (working or release)
check graceful exit status flag ( working or release )
dir
&Path
dir
&Path