代码拉取完成,页面将自动刷新
同步操作将从 lixiaoxu/mkfatfs 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
//
// main.cpp
// mkfatfs
//
// Created by Victor Mizikov on 20/09/2017.
// Copyright (c) 2017 Victor Mizikov. All rights reserved.
//
#include "Config.h"
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <time.h>
#include <memory>
#include <cstdlib>
#include "esp_err.h"
#include "esp_log.h"
#define TCLAP_SETBASE_ZERO 1
#include "tclap/CmdLine.h"
#include "tclap/UnlabeledValueArg.h"
#include "pack_fat.h"
#include "pack_littlefs.h"
#define APP_VERSION mkfatfs_VERSION
int g_debugLevel = 0;
enum Action { ACTION_NONE, ACTION_PACK, ACTION_UNPACK, ACTION_LIST, ACTION_VISUALIZE };
static Action s_action = ACTION_NONE;
static std::string s_dirName;
static std::string s_imageName;
static int s_imageSize;
static std::string s_fs;
void processArgs(int argc, const char** argv) {
TCLAP::CmdLine cmd("", ' ', APP_VERSION);
TCLAP::ValueArg<std::string> packArg( "c", "create", "create fatFS image from a directory", true, "", "pack_dir");
TCLAP::ValueArg<std::string> unpackArg( "u", "unpack", "unpack fatFS image to a directory", true, "", "dest_dir");
TCLAP::SwitchArg listArg( "l", "list", "list files in fatFS image", false);
TCLAP::SwitchArg visualizeArg( "i", "visualize", "visualize fatFS image", false);
TCLAP::UnlabeledValueArg<std::string> outNameArg( "image_file", "fatFS image file", true, "", "image_file" );
TCLAP::ValueArg<int> imageSizeArg( "s", "size", "fs image size, in bytes", false, 0x200000, "number" );
TCLAP::ValueArg<int> debugArg( "d", "debug", "Debug level. 0 means no debug output.", false, 0, "0-5" );
TCLAP::ValueArg<std::string> fsType( "t", "type", "Select file system type, suport fatfs littlefs now.", false, "fatfs", "fatfs or littlefs" );
cmd.add( imageSizeArg );
cmd.add(debugArg);
std::vector<TCLAP::Arg*> args = {&packArg, &unpackArg, &listArg, &visualizeArg};
cmd.xorAdd( args );
cmd.add( outNameArg );
cmd.add( fsType );
cmd.parse( argc, argv );
if (debugArg.getValue() > 0) {
std::cout << "Debug output enabled" << std::endl;
g_debugLevel = debugArg.getValue();
}
if (packArg.isSet()) {
s_dirName = packArg.getValue();
s_action = ACTION_PACK;
} else if (unpackArg.isSet()) {
s_dirName = unpackArg.getValue();
s_action = ACTION_UNPACK;
} else if (listArg.isSet()) {
s_action = ACTION_LIST;
} else if (visualizeArg.isSet()) {
s_action = ACTION_VISUALIZE;
}
s_imageName = outNameArg.getValue();
s_imageSize = imageSizeArg.getValue();
s_fs = fsType.getValue();
}
int main(int argc, const char * argv[]) {
try {
processArgs(argc, argv);
} catch(...) {
std::cerr << "Invalid arguments" << std::endl;
return 1;
}
Pack_fat pack_fat = Pack_fat();
Pack_littlefs pack_littlefs = Pack_littlefs();
switch (s_action) {
case ACTION_PACK:
if(s_fs == "fatfs")
return pack_fat.actionPack(s_dirName, s_imageName, s_imageSize);
else if(s_fs == "littlefs")
return pack_littlefs.actionPack(s_dirName, s_imageName, s_imageSize);
break;
case ACTION_UNPACK:
if(s_fs == "fatfs")
return pack_fat.actionUnpack(s_imageName, s_dirName, s_imageSize);
else if(s_fs == "littlefs")
return pack_littlefs.actionUnpack(s_imageName, s_dirName, s_imageSize);
break;
break;
case ACTION_LIST:
break;
case ACTION_VISUALIZE:
break;
default:
break;
}
return 1;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。