paco.cc
来自「About: Paco (pacKAGE oRGANIZER) is a si」· CC 代码 · 共 76 行
CC
76 行
//=======================================================================// paco.cc//-----------------------------------------------------------------------// This file is part of the package paco// Copyright (C) 2004-2007 David Rosal <david.3r@gmail.com>// For more information visit http://paco.sourceforge.net//=======================================================================#include "config.h"#include "paco.h"#include <sstream>#include <iomanip>#include <fnmatch.h>using std::string;using namespace Paco;//// Check whether @path matches any path in the colon-separated @list of paths.// Shell-like wildcards in @list are expanded.//bool Paco::inPaths(string const& path, string const& list){ std::istringstream s(list + ":"); string buf; while (getline(s, buf, ':') && buf.size()) { if (buf == "/" || !fnmatch(buf.c_str(), path.c_str(), 0) || !path.find(buf + "/")) return true; } return false;}string Paco::sizeStr(int unit, float size){ if (size < 0) return "@"; std::ostringstream s; if (unit <= 0) { // HUMAN_READABLE if (size < KILOBYTE) s << static_cast<int>(size); else if (size < MEGABYTE) s << static_cast<long>(size) / KILOBYTE << "k"; else if (size < (10 * MEGABYTE)) s << std::setprecision(2) << size / MEGABYTE << "M"; else s << static_cast<long>(size / MEGABYTE) << "M"; } else s << static_cast<long>(size / unit); return s.str();}string Paco::sizeStr(int unit, long size){ return sizeStr(unit, static_cast<float>(size));}X::X(string const& msg): std::runtime_error(msg){ }XErrno::XErrno(string const& msg): std::runtime_error(msg + ": " + strerror(errno)){ }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?