Searching way of hidden files was changed
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
[ sfv_md5.exe - version 1.2.8.4 or later ]
|
[ sfv_md5.exe - version 1.3.2.8 or later ]
|
||||||
|
|
||||||
Type "sfv_md5.exe" to see version and show usage below.
|
Type "sfv_md5.exe" to see version and show usage below.
|
||||||
|
|
||||||
@@ -64,7 +64,8 @@ A short filename in a path will be converted to long filename.
|
|||||||
If it is "*", all files in the specified directory are searched.
|
If it is "*", all files in the specified directory are searched.
|
||||||
If these are "*.txt" and "*.doc", files with extensions ".txt" and ".doc"
|
If these are "*.txt" and "*.doc", files with extensions ".txt" and ".doc"
|
||||||
in the specified directory are searched.
|
in the specified directory are searched.
|
||||||
Hidden files are ignored by search. (you can add each by exact filename.)
|
When you don't see hidden files on Windows Explorer, they are ignored by search.
|
||||||
|
If you want to search hidden files, change Windows Explorer setting to see them.
|
||||||
|
|
||||||
[input files] can be folder, though the folder itself is ignored.
|
[input files] can be folder, though the folder itself is ignored.
|
||||||
If it is "folder_name", files in the folder are searched.
|
If it is "folder_name", files in the folder are searched.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// common.c
|
// common.c
|
||||||
// Copyright : 2022-01-20 Yutaka Sawada
|
// Copyright : 2023-03-14 Yutaka Sawada
|
||||||
// License : The MIT license
|
// License : The MIT license
|
||||||
|
|
||||||
#ifndef _UNICODE
|
#ifndef _UNICODE
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <shlobj.h>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
@@ -1013,3 +1014,26 @@ void print_win32_err(void)
|
|||||||
LocalFree(lpMsgBuf);
|
LocalFree(lpMsgBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// エクスプローラーで隠しファイルを表示する設定になってるか調べる
|
||||||
|
unsigned int get_show_hidden(void)
|
||||||
|
{
|
||||||
|
unsigned int rv;
|
||||||
|
SHELLSTATE ssf;
|
||||||
|
|
||||||
|
// Explorer の設定を調べる
|
||||||
|
SHGetSetSettings(&ssf, SSF_SHOWALLOBJECTS | SSF_SHOWSUPERHIDDEN, FALSE);
|
||||||
|
// 隠しファイルを表示するかどうか
|
||||||
|
if (ssf.fShowAllObjects){ // 表示する設定なら
|
||||||
|
// 保護されたオペレーティングシステムファイルを表示するかどうか
|
||||||
|
if (ssf.fShowSuperHidden){ // 表示する設定なら
|
||||||
|
rv = 0;
|
||||||
|
} else { // 隠し属性とシステム属性の両方で判定する
|
||||||
|
rv = FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM;
|
||||||
|
}
|
||||||
|
} else { // 隠しファイルを表示しない場合は、隠し属性だけで判定する
|
||||||
|
rv = FILE_ATTRIBUTE_HIDDEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -137,3 +137,6 @@ void print_progress_done(void);
|
|||||||
// Win32 API のエラー・メッセージを表示する
|
// Win32 API のエラー・メッセージを表示する
|
||||||
void print_win32_err(void);
|
void print_win32_err(void);
|
||||||
|
|
||||||
|
// エクスプローラーで隠しファイルを表示する設定になってるか調べる
|
||||||
|
unsigned int get_show_hidden(void);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// main.c
|
// main.c
|
||||||
// Copyright : 2022-02-25 Yutaka Sawada
|
// Copyright : 2023-03-14 Yutaka Sawada
|
||||||
// License : The MIT license
|
// License : The MIT license
|
||||||
|
|
||||||
#ifndef _UNICODE
|
#ifndef _UNICODE
|
||||||
@@ -99,7 +99,12 @@ static wchar_t * search_files(
|
|||||||
wchar_t *list_buf, // ファイル・リスト
|
wchar_t *list_buf, // ファイル・リスト
|
||||||
wchar_t *search_path, // 検索するファイルのフル・パス
|
wchar_t *search_path, // 検索するファイルのフル・パス
|
||||||
long dir_len, // ディレクトリ部分の長さ
|
long dir_len, // ディレクトリ部分の長さ
|
||||||
long file_only, // ファイルのみにするかどうか
|
//long file_only, // ファイルのみにするかどうか
|
||||||
|
|
||||||
|
unsigned int filter, // 2, FILE_ATTRIBUTE_HIDDEN = 隠しファイルを無視する
|
||||||
|
// 4, FILE_ATTRIBUTE_SYSTEM = システムファイルを無視する
|
||||||
|
// 16, FILE_ATTRIBUTE_DIRECTORY = ディレクトリを無視する
|
||||||
|
|
||||||
long single_file, // -1 = *や?で検索指定、0~ = 単独指定
|
long single_file, // -1 = *や?で検索指定、0~ = 単独指定
|
||||||
long *list_max, // ファイル・リストの確保サイズ
|
long *list_max, // ファイル・リストの確保サイズ
|
||||||
long *list_len, // ファイル・リストの文字数
|
long *list_len, // ファイル・リストの文字数
|
||||||
@@ -107,9 +112,15 @@ static wchar_t * search_files(
|
|||||||
{
|
{
|
||||||
wchar_t *tmp_p;
|
wchar_t *tmp_p;
|
||||||
long len, l_max, l_off, dir_len2;
|
long len, l_max, l_off, dir_len2;
|
||||||
|
unsigned int attrib_filter;
|
||||||
HANDLE hFind;
|
HANDLE hFind;
|
||||||
WIN32_FIND_DATA FindData;
|
WIN32_FIND_DATA FindData;
|
||||||
|
|
||||||
|
// 隠しファイルを見つけるかどうか
|
||||||
|
attrib_filter = filter & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM);
|
||||||
|
if (attrib_filter == 0)
|
||||||
|
attrib_filter = INVALID_FILE_ATTRIBUTES;
|
||||||
|
|
||||||
if (list_buf == NULL){
|
if (list_buf == NULL){
|
||||||
l_off = 0;
|
l_off = 0;
|
||||||
l_max = ALLOC_LEN;
|
l_max = ALLOC_LEN;
|
||||||
@@ -128,7 +139,7 @@ static wchar_t * search_files(
|
|||||||
if (hFind == INVALID_HANDLE_VALUE)
|
if (hFind == INVALID_HANDLE_VALUE)
|
||||||
return list_buf; // 見つからなかったらそのまま
|
return list_buf; // 見つからなかったらそのまま
|
||||||
do {
|
do {
|
||||||
if ((single_file < 0) && (FindData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN))
|
if ((single_file < 0) && ((FindData.dwFileAttributes & attrib_filter) == attrib_filter))
|
||||||
continue; // 検索中は隠し属性が付いてるファイルを無視する
|
continue; // 検索中は隠し属性が付いてるファイルを無視する
|
||||||
|
|
||||||
len = wcslen(FindData.cFileName);
|
len = wcslen(FindData.cFileName);
|
||||||
@@ -144,14 +155,14 @@ static wchar_t * search_files(
|
|||||||
|
|
||||||
// フォルダなら
|
// フォルダなら
|
||||||
if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY){
|
if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY){
|
||||||
if ((file_only == 0) && wcscmp(FindData.cFileName, L".") && wcscmp(FindData.cFileName, L"..")){
|
if (((filter & FILE_ATTRIBUTE_DIRECTORY) == 0) && wcscmp(FindData.cFileName, L".") && wcscmp(FindData.cFileName, L"..")){
|
||||||
// フォルダの末尾は「\」にする
|
// フォルダの末尾は「\」にする
|
||||||
wcscat(search_path, L"\\");
|
wcscat(search_path, L"\\");
|
||||||
// そのフォルダの中身を更に検索する
|
// そのフォルダの中身を更に検索する
|
||||||
dir_len2 = wcslen(search_path);
|
dir_len2 = wcslen(search_path);
|
||||||
search_path[dir_len2 ] = '*'; // 末尾に「*」を追加する
|
search_path[dir_len2 ] = '*'; // 末尾に「*」を追加する
|
||||||
search_path[dir_len2 + 1] = 0;
|
search_path[dir_len2 + 1] = 0;
|
||||||
list_buf = search_files(list_buf, search_path, dir_len2, file_only, single_file, &l_max, &l_off, total_size);
|
list_buf = search_files(list_buf, search_path, dir_len2, filter, single_file, &l_max, &l_off, total_size);
|
||||||
if (list_buf == NULL){
|
if (list_buf == NULL){
|
||||||
FindClose(hFind);
|
FindClose(hFind);
|
||||||
printf("cannot search inner folder\n");
|
printf("cannot search inner folder\n");
|
||||||
@@ -761,6 +772,11 @@ fo= switch_set & 0x00000020
|
|||||||
wchar_t *list_buf;
|
wchar_t *list_buf;
|
||||||
long dir_len, list_len, list_max;
|
long dir_len, list_len, list_max;
|
||||||
__int64 total_size = 0; // 合計ファイル・サイズ
|
__int64 total_size = 0; // 合計ファイル・サイズ
|
||||||
|
unsigned int filter;
|
||||||
|
// 隠しファイルやフォルダーを無視するかどうか
|
||||||
|
filter = get_show_hidden();
|
||||||
|
if (switch_set & 0x20)
|
||||||
|
filter |= FILE_ATTRIBUTE_DIRECTORY;
|
||||||
// チェックサム・ファイル作成ならソース・ファイルのリストがいる
|
// チェックサム・ファイル作成ならソース・ファイルのリストがいる
|
||||||
i++;
|
i++;
|
||||||
if (i >= argc){
|
if (i >= argc){
|
||||||
@@ -797,7 +813,7 @@ fo= switch_set & 0x00000020
|
|||||||
while (file_path[dir_len] != '\\')
|
while (file_path[dir_len] != '\\')
|
||||||
dir_len--;
|
dir_len--;
|
||||||
dir_len++;
|
dir_len++;
|
||||||
list_buf = search_files(list_buf, file_path, dir_len, switch_set & 0x20, j, &list_max, &list_len, &total_size);
|
list_buf = search_files(list_buf, file_path, dir_len, filter, j, &list_max, &list_len, &total_size);
|
||||||
if (list_buf == NULL)
|
if (list_buf == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
if ((j != -1) && (j == file_num)){ // ファイルが見つかったか確かめる
|
if ((j != -1) && (j == file_num)){ // ファイルが見つかったか確かめる
|
||||||
|
|||||||
Reference in New Issue
Block a user