本文整理汇总了C++中SdFat::rename方法的典型用法代码示例。如果您正苦于以下问题:C++ SdFat::rename方法的具体用法?C++ SdFat::rename怎么用?C++ SdFat::rename使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SdFat
的用法示例。
在下文中一共展示了SdFat::rename方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: move_handler
// for renaming files and dirs
boolean move_handler(AtMegaWebServer& web_server){
const char *path = web_server.get_path();
#if DEBUG
Serial << F("move_handler filename: ") << path << '\n';
#endif
const char* length_str = web_server.get_header_value("Content-Length");
int len = atoi(length_str);
Client& client = web_server.get_client();
int i = 0;
int baselen = 0;
char* c;
if((c = strrchr(path, '/'))) baselen = c - path + 1;
char buf[baselen + len + 1];
if(baselen) strncpy(buf, path, baselen);
i = baselen;
for(; i < (baselen + len) && web_server.waitClientAvailable(); i++) {
buf[i] = client.read();// (char)
}
buf[i] = 0;
#if DEBUG
Serial << buf << "|end: " << i << '\n';
#endif
if(i == (len + baselen)){
if(sdfat.rename(path, buf)){
#if DEBUG
Serial << "renaming: " << path << " to: " << buf << '\n';
#endif
web_server.sendHttpResult(200);
web_server << buf;
}else{
#if DEBUG
Serial << "renaming: failed\n" << buf << LF;
#endif
web_server.sendHttpResult(422);
}
}else{
web_server.sendHttpResult(404);
}
return true;
}