Git Product home page Git Product logo

Comments (5)

blang avatar blang commented on August 15, 2024

You're right, it might be useful to include but it also bloats the interfaces.
Currently you can use OpenFile(name, os.O_TRUNC, 0) to truncate a file.

from vfs.

wuman avatar wuman commented on August 15, 2024

What we need is the ability to truncate the file to a certain size, which is not provided by the OpenFile function.

I do see your concern about bloating the interface though. We will resort to forking the project if it is understandably not added to the interface.

from vfs.

blang avatar blang commented on August 15, 2024

You're absolutely right, that can't be covered with a workaround.
What do you think suits better: fs.Truncate(name,size) or file.Truncate(size).
I think it might be better to add this to the File interface, since that does not bloat Wrapper Filesystems but you have to open the file first to truncate it.

I honestly don't know many use cases for truncate anyway, so what do you think?

from vfs.

wuman avatar wuman commented on August 15, 2024

For our particular use case where we are implementing an atomic file queue, we only need the file.Truncate(size) API. I think it makes more sense to add this because it doesn't bloat the Filesystem interface.

from vfs.

blang avatar blang commented on August 15, 2024

Yep i guess that's the best option. Are you already implementing this feature?

from vfs.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.