#include <errno.h>
#include <limits.h>
#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include <ogg/ogg.h>
#include <vorbis/codec.h>
#include <assert.h>
vorbis_info vi;
FILE *in;
+ mode_t file_mode;
+
bool opened;
long serial;
unsigned char *mainbuf;
ogg_packet *header;
ogg_packet header_main, header_comments, header_codebooks;
ogg_page og;
+ struct stat st;
char *buffer;
size_t bytes, total = 0;
int i = 0;
if (!s->in)
return VCEDIT_ERR_OPEN;
+ s->file_mode = stat (s->filename, &st) ? 0664 : st.st_mode;
+
ogg_sync_init (&s->oy);
do {
fclose (out);
unlink (s->filename);
rename (tmpfile, s->filename);
+ chmod (s->filename, s->file_mode);
}
ogg_stream_clear (&streamout);
end
end
+ def test_write_keeps_file_mode
+ mode = File.stat(OGG_FILE).mode
+
+ Ogg::Vorbis::Tagger.open(OGG_FILE) do |t|
+ t.write
+ end
+
+ assert_equal(mode, File.stat(OGG_FILE).mode)
+ end
+
def test_append
Ogg::Vorbis::Tagger.open(OGG_FILE) do |t|
t.comments["genre"] = "Death Metal"