Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Commit

Permalink
improve path handling, update workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Benjamin Ries committed Jun 21, 2023
1 parent 1f7afe5 commit 62bd5f0
Show file tree
Hide file tree
Showing 9 changed files with 8,494 additions and 7,182 deletions.
40 changes: 40 additions & 0 deletions Utilities/StringUtilities.cs
Expand Up @@ -3,7 +3,9 @@
// File: StringUtilities.cs

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Utilities
Expand Down Expand Up @@ -40,5 +42,43 @@ public static bool WriteAllTextNoBom(string path, string content, out string err
return false;
}
}

public static string RemoveInvalidFileNameChars(this string filename)
{
if (string.IsNullOrEmpty(filename)) return filename;
var parts = filename.Split(new[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
if (parts.Length == 0) return filename;

var fname = parts.Last();
var p = filename;
p = p.Replace(fname, string.Empty);
p = p.TrimEnd(new[] {'/'});

fname = string.Join("_", fname.Split(Path.GetInvalidFileNameChars()));
return Path.Combine(p, fname);
}

private static readonly List<string> ImageExtensions = new()
{
".jpg",
".jpeg",
".png",
".gif",
".bmp",
".tif",
".tiff",
".ico",
".svg"
};

public static bool IsImageFileExtension(this string filename)
{
if (string.IsNullOrEmpty(filename)) return false;
foreach(var it in ImageExtensions)
if (filename.EndsWith(it, StringComparison.OrdinalIgnoreCase))
return true;

return false;
}
}
}
60 changes: 4 additions & 56 deletions Workspaces/Basement/fbevents.json
Expand Up @@ -659,58 +659,6 @@
"AdditionalBlockLocks": [],
"LockedByBlock": ""
},
{
"BlockId": "B25[+]",
"FbEnter": "FB27",
"FbIn": "FB26",
"OnStart": [],
"OnStop": [],
"DeniedLocomotives": [],
"Settings": {
"BlockEnabled": true,
"OptionWait": true,
"OptionDirection": false,
"OptionMainline": true,
"OptionBbt": false,
"TypeOthers": true,
"TypeLocal": true,
"TypeIntercity": false,
"TypeFreight": true,
"TypeShunting": true,
"TypeBranchLine": true,
"TypeBranchLineFreight": false,
"TypeRegional": true
},
"AdditionalBlockLocks": [
"B09"
],
"LockedByBlock": ""
},
{
"BlockId": "B25[-]",
"FbEnter": "FB26",
"FbIn": "FB27",
"OnStart": [],
"OnStop": [],
"DeniedLocomotives": [],
"Settings": {
"BlockEnabled": true,
"OptionWait": true,
"OptionDirection": false,
"OptionMainline": true,
"OptionBbt": false,
"TypeOthers": true,
"TypeLocal": true,
"TypeIntercity": false,
"TypeFreight": true,
"TypeShunting": true,
"TypeBranchLine": true,
"TypeBranchLineFreight": false,
"TypeRegional": true
},
"AdditionalBlockLocks": [],
"LockedByBlock": ""
},
{
"BlockId": "B15[+]",
"FbEnter": "",
Expand Down Expand Up @@ -863,7 +811,7 @@
"OnStop": [],
"DeniedLocomotives": [],
"Settings": {
"BlockEnabled": true,
"BlockEnabled": false,
"OptionWait": true,
"OptionDirection": false,
"OptionMainline": true,
Expand All @@ -887,7 +835,7 @@
"OnStop": [],
"DeniedLocomotives": [],
"Settings": {
"BlockEnabled": true,
"BlockEnabled": false,
"OptionWait": true,
"OptionDirection": false,
"OptionMainline": true,
Expand All @@ -911,7 +859,7 @@
"OnStop": [],
"DeniedLocomotives": [],
"Settings": {
"BlockEnabled": true,
"BlockEnabled": false,
"OptionWait": true,
"OptionDirection": false,
"OptionMainline": true,
Expand All @@ -935,7 +883,7 @@
"OnStop": [],
"DeniedLocomotives": [],
"Settings": {
"BlockEnabled": true,
"BlockEnabled": false,
"OptionWait": true,
"OptionDirection": false,
"OptionMainline": true,
Expand Down
4 changes: 2 additions & 2 deletions Workspaces/Basement/locomotives.json
@@ -1,6 +1,6 @@
{
"1004": {
"IsCleaner": true,
"IsCleaner": false,
"IsStopped": true,
"IsLocked": false,
"Settings": {
Expand Down Expand Up @@ -605,7 +605,7 @@
"1003": {
"IsCleaner": false,
"IsStopped": true,
"IsLocked": true,
"IsLocked": false,
"Settings": {
"OptionDirection": false,
"OptionMainline": false,
Expand Down

0 comments on commit 62bd5f0

Please sign in to comment.