{"modulePath":"github.com/PathDNA/cfile","version":"v0.0.0-20171116200506-285d4ba46b29","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package cfile\n\n## Types\n\n```go\ntype Appender struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (a *Appender) Close() (err error)\n```\n\n```go\nfunc (a *Appender) Sync() (err error)\n```\n\n```go\nfunc (a *Appender) Write(b []byte) (n int, err error)\n```\n\n```go\ntype File struct {\n\tSyncAfterWriterClose bool // if set to true, calling `Writer.Close()`, will call `*os.File.Sync()`.\n\t// contains filtered or unexported fields\n}\n```\nFile is an \\`\\*os.File\\` wrapper that allows multiple readers or one writer or appender on a single file descriptor.\n\n```go\nfunc FromFile(in *os.File) (f *File, err error)\n```\nFromFile returns a \\`\\*File\\` from an \\`\\*os.File\\`. Using \\`f.Writer\\` requires that the file to \\*not\\* be opened with os.O\\_APPEND. On success, the returned \\`\\*File\\` will handle closing the \\`\\*os.File\\`.\n\n```go\nfunc New(fp string, perm os.FileMode) (*File, error)\n```\nNew opens \\`fp“ with \\`os.O\\_CREATE|os.O\\_RDWR“ and the given permissions.\n\n```go\nfunc TempFile(dir, prefix string) (*File, error)\n```\nTempFile is a convenience wrapper for \\`ioutil.TempFile\\`. Remember to clean up by calling \\`os.Remove(f.Name())\\` when you're done.\n\n```go\nfunc (f *File) Appender() *Appender\n```\nAppender returns an \\`\\*Appender\\` that can be used with any active Readers.\n\n```go\nfunc (f *File) Close() error\n```\nClose waits for all the active readers/writer to finish before closing the underlying \\`\\*os.File\\`.\n\n```go\nfunc (f *File) Fd() int\n```\nFd returns the underlying \\`\\*os.File\\`'s file descriptor.\n\n```go\nfunc (f *File) ForceClose() error\n```\nForceClose will close the underlying \\`\\*os.File\\` without waiting for any active readers/writer.\n\n```go\nfunc (f *File) Name() string\n```\nName returns the name of the file.\n\n```go\nfunc (f *File) Read(b []byte) (n int, err error)\n```\nReadAt implements \\`io.Read\\`. Note that it will always start at offset 0.\n\n```go\nfunc (f *File) ReadAt(b []byte, off int64) (n int, err error)\n```\nReadAt implements \\`io.ReaderAt\\`.\n\n```go\nfunc (f *File) ReadFrom(rd io.Reader) (n int64, err error)\n```\nReadFrom implements \\`io.ReaderFrom\\`. Appends to the end of the file.\n\n```go\nfunc (f *File) Reader() *Reader\n```\nReader returns f.SectionReader(0, -1).\n\n```go\nfunc (f *File) ReaderAt(off int64) *Reader\n```\nReaderAt returns f.SectionReader(off, -1).\n\n```go\nfunc (f *File) SectionReader(off, n int64) *Reader\n```\nSectionReader returns a SectionReader that reads from f starting at offset off and stops with EOF after n bytes. if n - 1, it will read the entire file.\n\n```go\nfunc (f *File) Size() int64\n```\nSize returns the current file size. the size is cached after each writer is closed, so it doesn't call Stat().\n\n```go\nfunc (f *File) Stat() (fi os.FileInfo, err error)\n```\nStat calls the underlying \\`\\*os.File.Stat()\\`. Will block if there are any active appenders or writers.\n\n```go\nfunc (f *File) Truncate(sz int64) (err error)\n```\nTruncate truncates the underlying \\`\\*os.File\\` to the specific size.\n\n```go\nfunc (f *File) With(fn func(*os.File) error) (err error)\n```\nWith acquires a write lock and calls fn with the underlying \\`\\*os.File\\` and returns any errors it returns.\n\n```go\nfunc (f *File) Write(b []byte) (n int, err error)\n```\nWrite wraps \\`f.Appender().Write\\` for convenience. If expecting multiple \\`Write\\` calls, use \\`f.Appender()“ directly.\n\n```go\nfunc (f *File) WriteAt(b []byte, off int64) (n int, err error)\n```\nWriteAt implements \\`io.WriterAt\\`.\n\n```go\nfunc (f *File) WriteTo(w io.Writer) (n int64, err error)\n```\nWriteTo implements \\`io.WriterTo\\`.\n\n```go\nfunc (f *File) Writer() *Writer\n```\nWriter returns f.WriteAt(-1).\n\n```go\nfunc (f *File) WriterAt(off int64) *Writer\n```\nWriterAt acquires a write-lock, seeks to the given offset and returns a writer. if off is \\\u003c 0, it seeks to the end of the file, otherwise it seeks to the off value.\n\n```go\ntype Reader struct {\n\t// contains filtered or unexported fields\n}\n```\nReader implements \\`io.Reader\\`, \\`io.ReaderAt\\`, \\`io.Seeker\\` and \\`io.Closer\\`.\n\n```go\nfunc (r *Reader) Close() error\n```\nClose releases the parent's read-lock.\n\n```go\nfunc (r *Reader) Read(b []byte) (int, error)\n```\nRead implements \\`io.Read\\`.\n\n```go\nfunc (r *Reader) ReadAt(b []byte, off int64) (int, error)\n```\nReadAt implements \\`io.ReaderAt\\`.\n\n```go\nfunc (r *Reader) Seek(offset int64, whence int) (int64, error)\n```\nSeek implements \\`io.Seeker\\`.\n\n```go\nfunc (r *Reader) Size() int64\n```\n\n```go\ntype Writer struct {\n\t// contains filtered or unexported fields\n}\n```\nWriter implements \\`io.Writer\\`, \\`io.WriterAt\\`, \\`io.Seeker“ and \\`io.Closer\\`.\n\n```go\nfunc (w *Writer) Close() (err error)\n```\nClose releases the parent's write-lock.\n\n```go\nfunc (w *Writer) Seek(offset int64, whence int) (n int64, err error)\n```\nSeek implements \\`io.Seeker\\`.\n\n```go\nfunc (w *Writer) Write(b []byte) (n int, err error)\n```\nWrite implements \\`io.Writer\\`.\n\n```go\nfunc (w *Writer) WriteAt(b []byte, off int64) (n int, err error)\n```\nWriteAt implements \\`io.WriterAt\\`.\n\n","path":"github.com/PathDNA/cfile","name":"cfile","synopsis":"","isRedistributable":true}
