comparison dep/animia/src/fd/linux.cc @ 156:cdf79282d647

dep/animia: add VERY early x11 window stuff
author Paper <mrpapersonic@gmail.com>
date Wed, 15 Nov 2023 18:04:04 -0500
parents d43d68408d3c
children 44c5e6dd9488
comparison
equal deleted inserted replaced
155:d2bbb5773616 156:cdf79282d647
1 #include "animia/util.h"
2 #include "animia/fd/linux.h" 1 #include "animia/fd/linux.h"
3 #include "animia.h" 2 #include "animia.h"
3 #include "animia/util.h"
4 4
5 #include <algorithm> 5 #include <algorithm>
6 #include <cstring>
6 #include <filesystem> 7 #include <filesystem>
7 #include <fstream> 8 #include <fstream>
8 #include <sstream> 9 #include <sstream>
9 #include <string> 10 #include <string>
10 #include <unordered_map> 11 #include <unordered_map>
11 #include <vector> 12 #include <vector>
12 #include <cstring>
13 13
14 #include <dirent.h>
14 #include <fcntl.h> 15 #include <fcntl.h>
15 #include <dirent.h>
16 #include <sys/stat.h> 16 #include <sys/stat.h>
17 #include <unistd.h> 17 #include <unistd.h>
18 18
19 #define PROC_LOCATION "/proc" 19 #define PROC_LOCATION "/proc"
20 20
56 { 56 {
57 std::string data; 57 std::string data;
58 if (!util::ReadFile(path, data)) 58 if (!util::ReadFile(path, data))
59 return false; 59 return false;
60 buffer << data; 60 buffer << data;
61 } 61 }
62 62
63 int flags = 0; 63 int flags = 0;
64 for (std::string line; std::getline(buffer, line);) { 64 for (std::string line; std::getline(buffer, line);) {
65 /* FIXME: exception handling here!! */ 65 /* FIXME: exception handling here!! */
66 if (line.rfind("flags:", 0) == 0) { 66 if (line.rfind("flags:", 0) == 0) {
73 } 73 }
74 74
75 static std::string GetFilenameFromFd(std::string link) { 75 static std::string GetFilenameFromFd(std::string link) {
76 /* gets around stupid linux limitation where /proc doesn't 76 /* gets around stupid linux limitation where /proc doesn't
77 give actual filesize readings */ 77 give actual filesize readings */
78 size_t exe_size = 1024; 78 size_t exe_size = 1024;
79 ssize_t exe_used; 79 ssize_t exe_used;
80 std::string ret; 80 std::string ret;
81 81
82 while (1) { 82 while (1) {
83 ret = std::string(exe_size, '\0'); 83 ret = std::string(exe_size, '\0');