comparison src/Input/modplug/archive/arch_raw.cxx @ 0:13389e613d67 trunk

[svn] - initial import of audacious-plugins tree (lots to do)
author nenolod
date Mon, 18 Sep 2006 01:11:49 -0700
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:13389e613d67
1 /* Modplug XMMS Plugin
2 * Authors: Kenton Varda <temporal@gauge3d.org>
3 *
4 * This source code is public domain.
5 */
6
7 //open()
8 #include <sys/types.h>
9 #include <sys/stat.h>
10 #include <fcntl.h>
11 //mmap()
12 #include <unistd.h>
13 #include <sys/mman.h>
14
15 #include "arch_raw.h"
16
17 arch_Raw::arch_Raw(const string& aFileName)
18 {
19 mFileDesc = open(aFileName.c_str(), O_RDONLY);
20
21 struct stat lStat;
22
23 //open and mmap the file
24 if(mFileDesc == -1)
25 {
26 mSize = 0;
27 return;
28 }
29 fstat(mFileDesc, &lStat);
30 mSize = lStat.st_size;
31
32 mMap =
33 (uchar*)mmap(0, mSize, PROT_READ,
34 MAP_PRIVATE, mFileDesc, 0);
35 if(!mMap)
36 {
37 close(mFileDesc);
38 mSize = 0;
39 return;
40 }
41 }
42
43 arch_Raw::~arch_Raw()
44 {
45 if(mSize != 0)
46 {
47 munmap(mMap, mSize);
48 close(mFileDesc);
49 }
50 }
51
52 bool arch_Raw::ContainsMod(const string& aFileName)
53 {
54 return IsOurFile(aFileName);
55 }