MCPcopy Create free account
hub / github.com/boostorg/filesystem / cpp_main

Function cpp_main

test/windows_attributes.cpp:27–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25namespace fs = boost::filesystem;
26
27int cpp_main(int argc, char* argv[])
28{
29 typedef std::map< DWORD, std::string > decode_type;
30 decode_type table;
31
32 table.insert(make_pair< DWORD, std::string >(FILE_ATTRIBUTE_ARCHIVE, "FILE_ATTRIBUTE_ARCHIVE"));
33 table.insert(make_pair< DWORD, std::string >(FILE_ATTRIBUTE_COMPRESSED, "FILE_ATTRIBUTE_COMPRESSED"));
34 table.insert(make_pair< DWORD, std::string >(FILE_ATTRIBUTE_DEVICE, "FILE_ATTRIBUTE_DEVICE"));
35 table.insert(make_pair< DWORD, std::string >(FILE_ATTRIBUTE_DIRECTORY, "FILE_ATTRIBUTE_DIRECTORY"));
36 table.insert(make_pair< DWORD, std::string >(FILE_ATTRIBUTE_ENCRYPTED, "FILE_ATTRIBUTE_ENCRYPTED"));
37 table.insert(make_pair< DWORD, std::string >(FILE_ATTRIBUTE_HIDDEN, "FILE_ATTRIBUTE_HIDDEN"));
38 table.insert(make_pair< DWORD, std::string >(FILE_ATTRIBUTE_NOT_CONTENT_INDEXED, "FILE_ATTRIBUTE_NOT_CONTENT_INDEXED"));
39 table.insert(make_pair< DWORD, std::string >(FILE_ATTRIBUTE_OFFLINE, "FILE_ATTRIBUTE_OFFLINE"));
40 table.insert(make_pair< DWORD, std::string >(FILE_ATTRIBUTE_READONLY, "FILE_ATTRIBUTE_READONLY"));
41 table.insert(make_pair< DWORD, std::string >(FILE_ATTRIBUTE_REPARSE_POINT, "FILE_ATTRIBUTE_REPARSE_POINT"));
42 table.insert(make_pair< DWORD, std::string >(FILE_ATTRIBUTE_SPARSE_FILE, "FILE_ATTRIBUTE_SPARSE_FILE"));
43 table.insert(make_pair< DWORD, std::string >(FILE_ATTRIBUTE_SYSTEM, "FILE_ATTRIBUTE_SYSTEM"));
44 table.insert(make_pair< DWORD, std::string >(FILE_ATTRIBUTE_TEMPORARY, "FILE_ATTRIBUTE_TEMPORARY"));
45 table.insert(make_pair< DWORD, std::string >(FILE_ATTRIBUTE_VIRTUAL, "FILE_ATTRIBUTE_VIRTUAL"));
46
47 if (argc < 2)
48 {
49 std::cout << "Usage: windows_attributes path\n";
50 return 1;
51 }
52
53 // report Win32 ::GetFileAttributesA()
54
55 DWORD at(::GetFileAttributesA(argv[1]));
56 if (at == INVALID_FILE_ATTRIBUTES)
57 {
58 std::cout << "GetFileAttributes(\"" << argv[1]
59 << "\") returned INVALID_FILE_ATTRIBUTES\n";
60 return 0;
61 }
62
63 std::cout << "GetFileAttributes(\"" << argv[1]
64 << "\") returned ";
65
66 bool bar = false;
67 for (decode_type::iterator it = table.begin(); it != table.end(); ++it)
68 {
69 if (!(it->first & at))
70 continue;
71 if (bar)
72 std::cout << " | ";
73 bar = true;
74 std::cout << it->second;
75 at &= ~it->first;
76 }
77 std::cout << std::endl;
78
79 if (at)
80 std::cout << "plus unknown attributes " << at << std::endl;
81
82 // report Boost Filesystem file_type
83
84 fs::file_status stat = fs::status(argv[1]);

Callers

nothing calls this directly

Calls 4

typeMethod · 0.80
statusFunction · 0.50
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected