スレ立てるまでもない質問はここで 101匹目
■ このスレッドは過去ログ倉庫に格納されています
0296デフォルトの名無しさん
2009/10/13(火) 12:33:55#include <iostream>
#include <vector>
#include <string>
#include <windows.h>
using namespace std;
class NODE { public: wstring name; unsigned int oya_node; vector<unsigned int> ko_node;
NODE(wstring fn) { oya_node=UINT_MAX; name=fn; }
NODE(int oya, wstring fn) { oya_node=oya; name=fn; }
void ko_node_search(vector<wstring>&); wstring fullpath(); };
vector<NODE> node;
void NODE::ko_node_search(vector<wstring> &x ) {
HANDLE hd; WIN32_FIND_DATAW fd;
wstring fn = fullpath() + L"\\*"; wcout<<"search "<<fn<<endl;
hd = FindFirstFileW(fn.c_str(), &fd);
do { wstring s=fd.cFileName;
if( s[0]!=L'.' || ( s[1]!=L'.' && s[1]!=L'\0') ) {
int n=s.rfind(L"\\"); x.push_back( s.substr(n+1) );
}}while(FindNextFileW(hd, &fd)); CloseHandle(hd); }
wstring NODE::fullpath(){ NODE x=*this; wstring s=x.name;
while(x.oya_node!=UINT_MAX){ x=node[x.oya_node]; s=x.name + L"\\" + s; } return s; }
int main(){ unsigned int n,k; vector<wstring> x;
node.push_back(NODE(L"c:"));
for(n=0; n<node.size(); n++){
node[n].ko_node_search(x);
for(k=0; k<x.size(); k++) {
node.push_back(NODE(n, x[k]));
node[n].ko_node.push_back(node.size()-1); } }}
■ このスレッドは過去ログ倉庫に格納されています