Skip to content

Commit

Permalink
add a 64-bit version for addressing more memory
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas694 committed Jun 28, 2024
1 parent 01cdfd6 commit 2dec550
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 9 deletions.
6 changes: 4 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ init:
#version: 1.0.{build}
image: Visual Studio 2019
configuration: Release
platform: Win32
platform:
- Win32
- x64
for:
-
branches:
Expand All @@ -27,7 +29,7 @@ build:
project: finddupe.sln
verbosity: normal
artifacts:
- path: Release/*.exe
- path: $(platform)/Release/*.exe
name: finddupe
deploy:
release: finddupe-v$(MY_BUILD_VERSION)
Expand Down
14 changes: 8 additions & 6 deletions finddupe.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
// Version 1.33 (c) Jun 2024 thomas694
// fixed a problem writing filenames with special unicode characters to the batch file
// fixed a memory problem with very large amounts of files
// added a 64-bit version for addressing more memory
//
// finddupe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -97,7 +98,7 @@ typedef struct {
}Checksum_t;

KHASH_MAP_INIT_INT64(hset, Checksum_t)
KHASH_MAP_INIT_INT64(hmap, INT32)
KHASH_MAP_INIT_INT64(hmap, UINT64)

// Data structure for file allocations:
typedef struct FileData_t FileData_t;
Expand Down Expand Up @@ -262,7 +263,7 @@ static khiter_t kh_put_fn(INT64 filenameCRC)
return k;
}

static khiter_t kh_get_fd(INT64 fileSize, int createNew, int* found)
static khiter_t kh_get_fd(UINT64 fileSize, int createNew, int* found)
{
khint_t k = kh_get(hmap, FileDataMap, fileSize);
if (k == kh_end(FileDataMap))
Expand All @@ -275,7 +276,7 @@ static khiter_t kh_get_fd(INT64 fileSize, int createNew, int* found)
return k;
}

static khiter_t kh_put_fd(INT64 fileSize)
static khiter_t kh_put_fd(UINT64 fileSize)
{
int ret;
khint_t k = kh_put(hmap, FileDataMap, fileSize, &ret);
Expand Down Expand Up @@ -1107,10 +1108,11 @@ int _tmain (int argc, TCHAR **argv)
}
#endif

if (BatchFileName){
if (BatchFileName) {
BatchFile = _tfopen(BatchFileName, TEXT("w"));
if (BatchFile == NULL){
_tprintf(TEXT("Unable to open task batch file '%s'\n"), BatchFileName);
if (BatchFile == NULL) {
_ftprintf(stderr, TEXT("Unable to open task batch file '%s'\n"), BatchFileName);
exit(EXIT_FAILURE);
}
_ftprintf(BatchFile, TEXT("@echo off\n"));
_ftprintf(BatchFile, TEXT("REM Batch file for replacing duplicates with hard links\n"));
Expand Down
9 changes: 9 additions & 0 deletions finddupe.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,25 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "finddupe", "finddupe.vcxpro
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|Win32 = Debug|Win32
Release|x64 = Release|x64
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5ACEBB24-9088-4D2B-9B89-0AABE4250D99}.Debug|x64.ActiveCfg = Debug|x64
{5ACEBB24-9088-4D2B-9B89-0AABE4250D99}.Debug|x64.Build.0 = Debug|x64
{5ACEBB24-9088-4D2B-9B89-0AABE4250D99}.Debug|Win32.ActiveCfg = Debug|Win32
{5ACEBB24-9088-4D2B-9B89-0AABE4250D99}.Debug|Win32.Build.0 = Debug|Win32
{5ACEBB24-9088-4D2B-9B89-0AABE4250D99}.Release|x64.ActiveCfg = Release|x64
{5ACEBB24-9088-4D2B-9B89-0AABE4250D99}.Release|x64.Build.0 = Release|x64
{5ACEBB24-9088-4D2B-9B89-0AABE4250D99}.Release|Win32.ActiveCfg = Release|Win32
{5ACEBB24-9088-4D2B-9B89-0AABE4250D99}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3A64AB72-6B0A-47D2-AD66-AF9F429A90A5}
EndGlobalSection
EndGlobal
71 changes: 71 additions & 0 deletions finddupe.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{5ACEBB24-9088-4D2B-9B89-0AABE4250D99}</ProjectGuid>
Expand All @@ -23,28 +31,61 @@
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<TargetName>$(ProjectName)_x64</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<TargetName>$(ProjectName)_x64</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
Expand All @@ -59,6 +100,19 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
Expand All @@ -76,6 +130,23 @@
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="finddupe.c" />
<ClCompile Include="myglob.c" />
Expand Down
2 changes: 1 addition & 1 deletion myglob.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ static void Recurse(const TCHAR * Pattern, int FollowReparse, void (*FileFuncPar
int NumHave = 0;

struct _tfinddata_t finddata;
long find_handle;
intptr_t find_handle;

find_handle = _tfindfirst(MatchPattern, &finddata);

Expand Down

0 comments on commit 2dec550

Please sign in to comment.