Skip to content
This repository has been archived by the owner on Jan 2, 2018. It is now read-only.

Commit

Permalink
Disabled unnecessary code, added a rule to ignore files starting with…
Browse files Browse the repository at this point in the history
… '.' (thanks Apple for this shit) and updated .rsf for newest makerom.
  • Loading branch information
profi200 committed Jan 5, 2016
1 parent 85ccfc2 commit fed1587
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 72 deletions.
6 changes: 3 additions & 3 deletions Makefile
Expand Up @@ -28,9 +28,9 @@ include $(DEVKITARM)/3ds_rules
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := source source/zip
SOURCES := source
DATA := data
INCLUDES := include include/zip
INCLUDES := include

APP_TITLE := sysUpdater
APP_DESCRIPTION := sysUpdater
Expand All @@ -42,7 +42,7 @@ ICON := /app/icon48x48.png
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard

CFLAGS := -g -Wall -O3 -flto -mword-relocations \
CFLAGS := -g -Wall -O2 -flto -mword-relocations \
-fomit-frame-pointer -ffast-math \
$(ARCH)

Expand Down
15 changes: 0 additions & 15 deletions app/build-cia.rsf
Expand Up @@ -27,21 +27,6 @@ Option:
EnableCrypt : false # Enables encryption for NCCH and CIA
MediaFootPadding : false # If true CCI files are created with padding

ExeFs: # these are the program segments from the ELF, check your elf for the appropriate segment names
ReadOnly:
- .rodata
- RO
ReadWrite:
- .data
- RO
Text:
- .init
- .text
- STUP_ENTRY

PlainRegion: # only used with SDK ELFs
# - .module_id

AccessControlInfo:
FileSystemAccess:
- DirectSdmc
Expand Down
8 changes: 4 additions & 4 deletions include/fs.h
Expand Up @@ -26,7 +26,7 @@
#include <vector>
#include <cstdio>
#include <3ds.h>
#include "zip.h"
//#include "zip.h"

#define FS_PATH_MAX_LENGTH (0x106)
#define MAX_BUF_SIZE (0x200000) // 2 MB
Expand Down Expand Up @@ -136,12 +136,12 @@ namespace fs


// Zip functions
void copyFileToZip(const std::u16string& src, const std::string& zipPath, zipFile& zip, std::function<void (const std::u16string& file, u32 percent)> callback=nullptr, FS_Archive& srcArchive=sdmcArchive);
/*void copyFileToZip(const std::u16string& src, const std::string& zipPath, zipFile& zip, std::function<void (const std::u16string& file, u32 percent)> callback=nullptr, FS_Archive& srcArchive=sdmcArchive);
void makeDirInZip(const std::string& zipPath, zipFile& zip);
void zipDir(const std::u16string& src, const std::u16string& zipDst, std::function<void (const std::u16string& fsObject, u32 totalPercent, u32 filePercent)> callback=nullptr, FS_Archive& srcArchive=sdmcArchive);
void unzipToDir(const std::u16string& zipSrc, const std::u16string& dst, std::function<void (const std::u16string& fsObject, u32 totalPercent, u32 filePercent)> callback=nullptr, FS_Archive& dstArchive=sdmcArchive);
void addToZipPath(std::string& path, const std::u16string& dirOrFile, bool isDir);
void removeFromZipPath(std::string& path);
void removeFromZipPath(std::string& path);*/


// Misc functions
Expand All @@ -150,7 +150,7 @@ namespace fs
} // namespace fs


Result FSUSER_ControlArchive(Handle *handle, FS_Archive *archive);
//Result FSUSER_ControlArchive(Handle *handle, FS_Archive *archive);
void sdmcArchiveInit();
void sdmcArchiveExit();

Expand Down
63 changes: 13 additions & 50 deletions source/fs.cpp
Expand Up @@ -25,8 +25,8 @@
#include <3ds.h>
#include "fs.h"
#include "misc.h"
#include "zip.h"
#include "unzip.h"
//#include "zip.h"
//#include "unzip.h"

#define _FILE_ "fs.cpp" // Replacement for __FILE__ without the path

Expand Down Expand Up @@ -565,7 +565,7 @@ namespace fs
// Zip related functions ||
//===============================================

void copyFileToZip(const std::u16string& src, const std::string& zipPath, zipFile& zip, std::function<void (const std::u16string& file, u32 percent)> callback, FS_Archive& srcArchive)
/*void copyFileToZip(const std::u16string& src, const std::string& zipPath, zipFile& zip, std::function<void (const std::u16string& file, u32 percent)> callback, FS_Archive& srcArchive)
{
File inFile(src, FS_OPEN_READ, srcArchive);
u64 inFileSize, offset = 0;
Expand All @@ -585,9 +585,9 @@ namespace fs
Buffer<u8> buffer(MAX_BUF_SIZE, false);
if((res = zipOpenNewFileInZip4(zip, zipPath.c_str(), &fileInfo, nullptr, 0, nullptr, 0, nullptr, Z_DEFLATED, Z_DEFAULT_COMPRESSION,
0, -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, nullptr, 0, 0, 0x800 /* UTF-8 flag */)) != ZIP_OK)
throw fsException(_FILE_, __LINE__, res, "Failed to create file in ZIP!");
if((res = zipOpenNewFileInZip4(zip, zipPath.c_str(), &fileInfo, nullptr, 0, nullptr, 0, nullptr, Z_DEFLATED, Z_DEFAULT_COMPRESSION,*/
//0, -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, nullptr, 0, 0, 0x800 /* UTF-8 flag */)) != ZIP_OK)
/*throw fsException(_FILE_, __LINE__, res, "Failed to create file in ZIP!");
for(u32 i=0; i<=inFileSize / MAX_BUF_SIZE; i++)
Expand Down Expand Up @@ -622,9 +622,9 @@ namespace fs
memcpy(&fileInfo.tmz_date, time_, 24); // Copy s, m, h, d and y directly
// That's the only way to make dirs? Wtf.
if((res = zipOpenNewFileInZip4(zip, zipPath.c_str(), &fileInfo, nullptr, 0, nullptr, 0, nullptr, Z_BINARY, Z_NO_COMPRESSION,
0, 0, 0, 0, nullptr, 0, 0, 0x800 /* UTF-8 flag */)) != ZIP_OK)
throw fsException(_FILE_, __LINE__, res, "Failed to create directory in ZIP!");
if((res = zipOpenNewFileInZip4(zip, zipPath.c_str(), &fileInfo, nullptr, 0, nullptr, 0, nullptr, Z_BINARY, Z_NO_COMPRESSION,*/
//0, 0, 0, 0, nullptr, 0, 0, 0x800 /* UTF-8 flag */)) != ZIP_OK)
/*throw fsException(_FILE_, __LINE__, res, "Failed to create directory in ZIP!");
if((res = zipCloseFileInZip(zip)) != ZIP_OK) throw fsException(_FILE_, __LINE__, res, "Failed to close directory in ZIP!");
}
Expand Down Expand Up @@ -743,9 +743,9 @@ namespace fs
}
else
{
tmpOutPath.clear();
if(fInfo.external_fa & 0x10) zipFilePath[strlen(&zipFilePath)-1] = 0; // Remove slash from path
utf8_to_utf16((u16*)&tmpOutPath, (u8*)&zipFilePath, 255);
tmpOutPath.clear();
if(fInfo.external_fa & 0x10) zipFilePath[strlen(&zipFilePath)-1] = 0; // Remove slash from path
utf8_to_utf16((u16*)&tmpOutPath, (u8*)&zipFilePath, 255);
if(fInfo.external_fa & 0x10)
{
Expand Down Expand Up @@ -803,7 +803,7 @@ namespace fs
else path.erase(found+1); // someDir/someDir/
}
}
}
}*/


//===============================================
Expand All @@ -827,43 +827,6 @@ namespace fs
} // namespace fs


// Currently unused code. May be useful later
// Commented out - do not know how to fix atm
/*Result FSUSER_ControlArchive(Handle *handle, FS_Archive *archive)
{
if(!archive)
return -2;
extern Handle fsuHandle;
if(!handle)
handle = &fsuHandle;
u32 b1, b2;
((u8*)&b1)[0] = 0x4E;
((u8*)&b2)[0] = 0xE4;
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x080D0144;
cmdbuf[1] = archive->lowPath;
cmdbuf[2] = archive->handle;
cmdbuf[3] = 0;
cmdbuf[4] = 1;
cmdbuf[5] = 1;
cmdbuf[6] = 0x1A;
cmdbuf[7] = (u32)&b1;
cmdbuf[8] = 0x1C;
cmdbuf[9] = (u32)&b2;
Result ret = 0;
if((ret = svcSendSyncRequest(*handle)))
return ret;
return cmdbuf[1];
}*/


void sdmcArchiveInit()
{
sdmcArchive = (FS_Archive){0x00000009, (FS_Path){PATH_EMPTY, 1, (u8*)""}};
Expand Down
6 changes: 6 additions & 0 deletions source/main.cpp
Expand Up @@ -144,6 +144,12 @@ void installUpdates(bool downgrade)
{
if(!it.isDir)
{
// Quick and dirty hack to detect these pesky
// attribute files OSX creates.
// This should rather be added to the
// filter rules later.
if(it.name[0] == u'.') continue;

f.open(u"/updates/" + it.name, FS_OPEN_READ);
if((res = AM_GetCiaFileInfo(MEDIATYPE_NAND, &ciaFileInfo, f.getFileHandle()))) throw titleException(_FILE_, __LINE__, res, "Failed to get CIA file info!");

Expand Down

0 comments on commit fed1587

Please sign in to comment.