Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ------------------------------------------------------------------------------------
- Void Resource::Manager::InitializeResourceLocation(const String& location)
- {
- Bool result;
- Directory folder;
- // Get all the files and folders in the location
- result = folder.Read(location);
- // If recursive, be recursive
- for(Int i = 0; i < folder.Folders.Count; ++i)
- {
- InitializeResourceLocation(location + folder.Folders[i] + "\\");
- }
- // Iterate through every located file
- for(Int i = 0; i < folder.Files.Count; ++i)
- {
- // Get the position of the extension separator
- UInt pos = folder.Files[i].rfind('.');
- //
- if(pos != std::string::npos)
- {
- // Get the extension
- String extension = folder.Files[i].substr(pos + 1);
- if(extension.length() == 3)
- {
- // Hash the extension for faster comparisons
- UInt hash = (extension[0] << 16) + (extension[1] << 8) + (extension[2]); //Hash::FNV32(extension.data(), extension.length());
- // Match the extension to a supported resource type
- switch(hash)
- {
- // Input layout file
- case 'lay':
- {
- Layouts.Expand(1);
- UInt slot = Layouts.Append();
- Layouts[slot].CreateFromFile(location + folder.Files[i]);
- break;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement