Skip to content

Commit

Permalink
Переделал программу под .NET 7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fdsc committed Jan 2, 2023
1 parent be65ddd commit f30f03f
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 95 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.vs
obj
bin
build
27 changes: 17 additions & 10 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,8 @@ public static int ExecuteSdels(string flagsOfAll, StreamReader stdR)
if (line == null)
break;

var sdelName = typeof(MainClass).Assembly.Location;
// var sdelName = typeof(MainClass)!.Assembly!.Location;
var sdelName = System.AppContext.BaseDirectory!;
var cmdLine = $"'{foa[1]}' '{line}'";
if (verbose > 0)
Console.WriteLine($"Start {sdelName} {cmdLine}");
Expand All @@ -533,6 +534,12 @@ public static int ExecuteSdels(string flagsOfAll, StreamReader stdR)
psi.RedirectStandardError = true;
using (var pi = Process.Start(psi))
{
if (pi == null)
{
rc = 1;
continue;
}

pi.WaitForExit();

if (pi.ExitCode != 0)
Expand Down Expand Up @@ -587,7 +594,7 @@ private static bool createFile(string path, Progress progress, int verbose)
DateTime now, dt = DateTime.MinValue;
TimeSpan ts;

FileStream fs = null;
FileStream? fs = null;
if (progress.createDirectoriesOnly <= 0)
try
{
Expand Down Expand Up @@ -671,7 +678,7 @@ private static bool createFile(string path, Progress progress, int verbose)
{
try
{
fs.Close();
fs?.Close();
}
catch
{ }
Expand Down Expand Up @@ -826,14 +833,14 @@ private static void deleteDir(DirectoryInfo dir, Progress progress, int verbose
sb.Append(ci, fn.Length);
fn = sb.ToString();
sb.Clear();
newFileName = Path.Combine(dir.Parent.FullName, fn);

newFileName = Path.Combine(dir!.Parent!.FullName!, fn);
if (File.Exists(newFileName) || Directory.Exists(newFileName))
{
continue;
}
dir.MoveTo(newFileName);

dir!.MoveTo(newFileName);
break;
}
catch (Exception e)
Expand Down Expand Up @@ -969,7 +976,7 @@ private static void deleteFile(FileInfo file, List<byte[]> bt, Progress progress
fn = sb.ToString();
sb.Clear();

newFileName = Path.Combine(file.DirectoryName, fn);
newFileName = Path.Combine(file.DirectoryName!, fn);
if (newFileName == oldFileName)
continue;

Expand All @@ -989,10 +996,10 @@ private static void deleteFile(FileInfo file, List<byte[]> bt, Progress progress
file.MoveTo(newFileName);
break;
}
catch (Exception e)
catch (Exception)
{
if (ci == 'z')
throw e;
throw;
}
}
}
Expand Down
26 changes: 0 additions & 26 deletions Properties/AssemblyInfo.cs

This file was deleted.

11 changes: 9 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
Русский ниже

# English
For Linux require to install Mono https://www.mono-project.com/
For Linux require to install [.NET 7.0](https://dotnet.microsoft.com/download)

Building for you system
cd you_directory_for_sdel
git clone https://github.com/VinnySmallUtilities/sdel
cd sdel
dotnet publish --output ./build -c Release --self-contained false /p:PublishSingleFile=true


The program erase the file (directory) with a single rewriting (data sanitization) of the data in it.

Expand Down Expand Up @@ -127,7 +134,7 @@ sdel


# Русский
На Linux требует установленной Mono https://www.mono-project.com/
На Linux требует установленной [.NET 7.0](https://dotnet.microsoft.com/download)

Программа удаляет файл (папку) с однократным перезатированием данных в нём.
Используется простая перезапись файла через функции ОС, не ждите ничего особенного.
Expand Down
47 changes: 7 additions & 40 deletions sdel.csproj
Original file line number Diff line number Diff line change
@@ -1,43 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProjectGuid>{74A8F333-4FDB-4104-979E-160B558779E0}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>sdel</RootNamespace>
<AssemblyName>sdel</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>embedded</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ExternalConsole>true</ExternalConsole>
<PlatformTarget>x86</PlatformTarget>
<LangVersion>Latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ExternalConsole>true</ExternalConsole>
<LangVersion>Latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="readme.md" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>

</Project>
17 changes: 0 additions & 17 deletions sdel.sln

This file was deleted.

0 comments on commit f30f03f

Please sign in to comment.