1 // Copyright (C) 2003-2008 Dolphin Project.
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, version 2.0.
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // GNU General Public License 2.0 for more details.
12 // A copy of the GPL 2.0 should have been included with the program.
13 // If not, see http://www.gnu.org/licenses/
15 // Official SVN repository and contact information can be found at
16 // http://code.google.com/p/dolphin-emu/
29 #include "Common.h" // Common
31 #include "LogManager.h"
33 #include "../../Core/Src/Core.h"
34 #include "../../Core/Src/ConfigManager.h"
35 #include "FileSystemGCWii.h"
36 #include "VolumeCreator.h"
41 DiscIO::IVolume
*OpenISO
= NULL
;
42 DiscIO::IFileSystem
*pFileSystem
= NULL
;
43 std::vector
<const DiscIO::SFileInfo
*> GCFiles
;
44 std::string ISOFile
= "", CurrentFile
= "";
45 bool FileAccess
= true;
48 bool ShowSound(std::string FileName
)
51 SplitPath(FileName
, NULL
, NULL
, &Ending
);
52 std::transform(Ending
.begin(),Ending
.end(),Ending
.begin(),::tolower
);
55 (Ending
== ".adp") // 1080 Avalanche, Crash Bandicoot, etc
56 || (Ending
== ".afc") // Zelda WW
57 || (Ending
== ".ast") // Zelda TP, Mario Kart
58 || (Ending
== ".dsp") // Metroid Prime
59 || (Ending
== ".hps") // SSB Melee
61 || (Ending
== ".brstm") // Wii Sports, Wario Land, etc
62 || (Ending
== ".sad") // Disaster
70 // Read the GC file system
71 void ReadGC(std::string FileName
)
73 // Should have an actual Shutdown procedure or something
79 if(pFileSystem
!= NULL
)
84 // GCFiles' pointers are no longer valid after pFileSystem is cleared
86 OpenISO
= DiscIO::CreateVolumeFromFilename(FileName
);
88 if (!DiscIO::IsVolumeWiiDisc(OpenISO
) && !DiscIO::IsVolumeWadFile(OpenISO
))
90 pFileSystem
= DiscIO::CreateFileSystem(OpenISO
);
91 if(!pFileSystem
) return;
92 pFileSystem
->GetFileList(GCFiles
);
97 // Check if we should play this file
98 void CheckFile(std::string File
, u64 Size
)
100 // Don't do anything if the log is unselected
101 if (!LogManager::GetInstance()->isEnable(LogTypes::FILEMON
)) return;
102 // Do nothing if we found the same file again
103 if (CurrentFile
== File
) return;
105 if (Size
> 0) Size
= (Size
/ 1000);
106 std::string Str
= StringFromFormat("%s kB %s", ThousandSeparate(Size
, 7).c_str(), File
.c_str());
109 NOTICE_LOG(FILEMON
, Str
.c_str());
113 WARN_LOG(FILEMON
, Str
.c_str());
116 // Update the current file
121 // Find the GC filename
122 void FindFilename(u64 offset
)
124 // Don't do anything if a game is not running
125 if (Core::GetState() != Core::CORE_RUN
) return;
126 // Or if the log is unselected
127 if (!LogManager::GetInstance()->isEnable(LogTypes::FILEMON
)) return;
128 if (!FileAccess
) return;
130 if (!pFileSystem
|| ISOFile
!= SConfig::GetInstance().m_LastFilename
)
133 ReadGC(SConfig::GetInstance().m_LastFilename
);
134 ISOFile
= SConfig::GetInstance().m_LastFilename
;
135 NOTICE_LOG(FILEMON
, "Opening '%s'", ISOFile
.c_str());
139 const char *fname
= pFileSystem
->GetFileName(offset
);
141 // There's something wrong with the paths
142 if (!fname
|| (strlen(fname
) == 512))
145 CheckFile(fname
, pFileSystem
->GetFileSize(fname
));
156 if(pFileSystem
!= NULL
)
162 // GCFiles' pointers are no longer valid after pFileSystem is cleared