From 0b90ab534f6ba1df4a6dea0bd3d6ae8bb6a8ab46 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Mon, 21 Nov 2011 00:12:20 +0100 Subject: [PATCH] ramfs now supports O_TRUNC. --- sortix/fs/ramfs.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sortix/fs/ramfs.cpp b/sortix/fs/ramfs.cpp index 8f841c25..66793233 100644 --- a/sortix/fs/ramfs.cpp +++ b/sortix/fs/ramfs.cpp @@ -263,7 +263,12 @@ namespace Sortix if ( files ) { size_t fileindex = files->Search(LookupFile, path); - if ( fileindex != SIZE_MAX ) { return files->Get(fileindex); } + if ( fileindex != SIZE_MAX ) + { + DevRAMFSFile* file = files->Get(fileindex); + if ( flags & O_TRUNC ) { file->Resize(0); } + return file; + } } return CreateFile(path, flags, mode);