Comments (5)
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.
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.
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.
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.
Yep i guess that's the best option. Are you already implementing this feature?
from vfs.
Related Issues (12)
- `Readlink` support
- `Chtimes` support
- S3 implementation
- Portability? HOT 2
- Exec? HOT 3
- memfs seems not work correctly?
- Can this be used with embed ?
- Sync() is missing from File abstraction HOT 1
- MkdirAll and RemoveAll are missing from filesystem abstraction HOT 11
- Filesystem.OpenFile returns vfs.File, not *vfs.File HOT 2
- Why takes memfs.NewBuffer a pointer to a []byte? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vfs.