C(UNIX系のみ),およびPerl(Win/UNIXともに)に存在する「opendir」「readdir」等に相当することをABで(=API等を用いて)することは可能なのでしょうか。
ただし,FindFirstFile/FindNextFileを使うものを除きます(その方法なら私も分かります)。
FindFirstFile/FindNextFileでダメということはありませんが,もし他の方法が可能ならその方が効率が良いと思ったからです。
opendir/readdirに対応するコマンド
opendir/readdirに対応するコマンド
' ============================================================
' Sinryow Game Home Page - http://www.sinryow.net/
' Sinryow ActiveBasic Center - http://ab.sinryow.net/
' ============================================================
' Sinryow Game Home Page - http://www.sinryow.net/
' Sinryow ActiveBasic Center - http://ab.sinryow.net/
' ============================================================
http://www.google.com/search?num=50&hl= ... lr=lang_ja
ここらへん使って少し調べてみましたがどうやらないようです。
Perl言語は確かインタプリンタ言語ですので、インタプリンタを逆アセンブラなどして解析してActiveBasicに移植するのが一番手っ取り早いかと。
http://www.vector.co.jp/vpack/filearea/ ... index.html
また、ベクターでopendirと調べて出てきた物からどんどんたどっていったらこんなページにたどり着きました。
http://www3.tky.3web.ne.jp/~arsene/hsp/force/
健闘を祈ります。
ここらへん使って少し調べてみましたがどうやらないようです。
Perl言語は確かインタプリンタ言語ですので、インタプリンタを逆アセンブラなどして解析してActiveBasicに移植するのが一番手っ取り早いかと。
http://www.vector.co.jp/vpack/filearea/ ... index.html
また、ベクターでopendirと調べて出てきた物からどんどんたどっていったらこんなページにたどり着きました。
http://www3.tky.3web.ne.jp/~arsene/hsp/force/
健闘を祈ります。
Website→http://web1.nazca.co.jp/himajinn13sei/top.html
ここ以外の場所では「暇人13世」というHNを主として使用。
に署名を書き換えて欲しいと言われたので暇だしやってみるテスト。
ここ以外の場所では「暇人13世」というHNを主として使用。
に署名を書き換えて欲しいと言われたので暇だしやってみるテスト。
Re: opendir/readdirに対応するコマンド
密かにWindows版のVC++でもopendirは使えます。> C(UNIX系のみ),およびPerl(Win/UNIXともに)に存在する「opendir」「readdir」等に相当することをABで(=API等を用いて)することは可能なのでしょうか。
(かなり使い方は異なっていますが… 感覚的にはfopenに近い)
fopenはcrtdllに入っているのでopendirも入っているかと調べてみても> ただし,FindFirstFile/FindNextFileを使うものを除きます(その方法なら私も分かります)。
dllにはopendirは含まれていないようなので、コンパイルされたEXEを探ったところVC++のopendirはVC++のコンパイラがFind~File系のAPIに置き換えているようです。ということでopendirに相当するAPIは無いっぽいです。
**追加情報 興味のある人だけどうぞ。** [ここをクリックすると内容が表示されます]
MSDNにUNIXからの移植サンプルがありました。
これを見る通りopendirの移植にはFind~File系のAPIを推奨しているようです。
コード: 全て選択
UNIX example 1: using directory handling functions
This sample prints out the current directory, and then recurses through subdirectories.
#include <unistd.h>
#include <stdio.h>
#include <dirent.h>
#include <string.h>
#include <sys/stat.h>
void ScanDir(char *dir, int indent)
{
DIR *dp;
struct dirent *dir_entry;
struct stat stat_info;
if((dp = opendir(dir)) == NULL) {
fprintf(stderr,"cannot open directory: %s\n", dir);
return;
}
chdir(dir);
while((dir_entry = readdir(dp)) != NULL) {
lstat(dir_entry->d_name,&stat_info);
if(S_ISDIR(stat_info.st_mode)) {
/* Directory, but ignore . and .. */
if(strcmp(".",dir_entry->d_name) == 0 ||
strcmp("..",dir_entry->d_name) == 0)
continue;
printf("%*s%s/\n",indent,"",dir_entry->d_name);
/* Recurse at a new indent level */
ScanDir(dir_entry->d_name,indent+4);
}
else printf("%*s%s\n",indent,"",dir_entry->d_name);
}
chdir("..");
closedir(dp);
}
int main(int argc, char* argv[])
{
char *topdir, defaultdir[2]=".";
if (argc != 2) {
printf("Argument not supplied - using current
directory.\n");
topdir=defaultdir;
}
else
topdir=argv[1];
printf("Directory scan of %s\n",topdir);
ScanDir(topdir,0);
printf("done.\n");
exit(0);
}
コード: 全て選択
Win32 example 1: using directory handling functions
This sample prints out the current directory, and then recurses through subdirectories. It uses the FindFirstFile(), FindNextFile(), and FindClose() Win32 API functions.
#include <windows.h>
#include <stdio.h>
void ScanDir(char *dirname, int indent)
{
BOOL fFinished;
HANDLE hList;
TCHAR szDir[MAX_PATH+1];
TCHAR szSubDir[MAX_PATH+1];
WIN32_FIND_DATA FileData;
// Get the proper directory path
sprintf(szDir, "%s\\*", dirname);
// Get the first file
hList = FindFirstFile(szDir, &FileData);
if (hList == INVALID_HANDLE_VALUE)
{
printf("No files found\n\n");
}
else
{
// Traverse through the directory structure
fFinished = FALSE;
while (!fFinished)
{
// Check the object is a directory or not
if (FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
if ((strcmp(FileData.cFileName, ".") != 0) &&
(strcmp(FileData.cFileName, "..") != 0))
{
printf("%*s%s\\\n", indent, "",
FileData.cFileName);
// Get the full path for sub directory
sprintf(szSubDir, "%s\\%s", dirname,
FileData.cFileName);
ScanDir(szSubDir, indent + 4);
}
}
else
printf("%*s%s\n", indent, "", FileData.cFileName);
if (!FindNextFile(hList, &FileData))
{
if (GetLastError() == ERROR_NO_MORE_FILES)
{
fFinished = TRUE;
}
}
}
}
FindClose(hList);
}
void main(int argc, char *argv[])
{
char *pszInputPath;
char pwd[2] = ".";
if (argc < 2)
{
printf("Argument not supplied - using current directory.\n");
pszInputPath = pwd;
}
else
{
pszInputPath = argv[1];
printf("Input Path: %s\n\n", pszInputPath);
}
ScanDir(pszInputPath, 0);
printf("\ndone.\n");
}
これを見る通りopendirの移植にはFind~File系のAPIを推奨しているようです。
こういった操作は最終的には全てOSのAPIを呼ぶしかないと思います。
つまり他の方法でもWindowsでは結局FindFirstFile/FindNextFileの呼び出しになるのではないでしょうか。
(FindFirstFile/FindNextFileを使わず直接ディスクから読み出すというのは考えないことにします)
つまり他の方法でもWindowsでは結局FindFirstFile/FindNextFileの呼び出しになるのではないでしょうか。
(FindFirstFile/FindNextFileを使わず直接ディスクから読み出すというのは考えないことにします)
最後に編集したユーザー イグトランス [ 2005年11月06日(日) 22:50 ], 累計 1 回
皆さん,ありがとうございます。
最終的にはすべてFind~Fileでやっているんですね。自分のものもFind~Fileで書くことにしました。
最終的にはすべてFind~Fileでやっているんですね。自分のものもFind~Fileで書くことにしました。
' ============================================================
' Sinryow Game Home Page - http://www.sinryow.net/
' Sinryow ActiveBasic Center - http://ab.sinryow.net/
' ============================================================
' Sinryow Game Home Page - http://www.sinryow.net/
' Sinryow ActiveBasic Center - http://ab.sinryow.net/
' ============================================================