Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 46 lines (42 sloc) 1.183 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
#include "path_info.h"
#include <scm/scm.h>
#include <settings/settings.h>
#include <io/entries.h>
#include <regexp/glob.h>
#include <plist/ascii.h>
#include <text/tokenize.h>
#include <oak/oak.h>
#include <oak/compat.h>

namespace file
{
std::string path_attributes (std::string const& path)
{
std::vector<std::string> res;
if(path != NULL_STR)
{
std::vector<std::string> revPath;
for(auto const& token : text::tokenize(path.begin(), path.end(), '/'))
{
std::string tmp = token;
for(auto const& subtoken : text::tokenize(tmp.begin(), tmp.end(), '.'))
{
if(subtoken.empty())
continue;
revPath.push_back(subtoken);
std::replace(revPath.back().begin(), revPath.back().end(), ' ', '_');
}
}
revPath.push_back("rev-path");
revPath.push_back("attr");
std::reverse(revPath.begin(), revPath.end());
res.push_back(text::join(revPath, "."));
}
else
{
res.push_back("attr.untitled");
}

res.push_back(text::format("attr.os-version.%zu.%zu.%zu", oak::os_major(), oak::os_minor(), oak::os_patch()));
res.erase(std::remove(res.begin(), res.end(), ""), res.end());
return text::join(res, " ");
}

} /* file */
Something went wrong with that request. Please try again.