mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-27 14:12:16 +00:00
91 lines
2.6 KiB
C#
91 lines
2.6 KiB
C#
|
|
||
|
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
||
|
|
||
|
/*
|
||
|
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
||
|
* This program is released under GNU General Public License
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU General Public License for more details.
|
||
|
*
|
||
|
*/
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region ================== Namespaces
|
||
|
|
||
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Globalization;
|
||
|
using System.Text;
|
||
|
using System.IO;
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
namespace CodeImp.DoomBuilder.IO
|
||
|
{
|
||
|
internal struct DirectoryFileEntry
|
||
|
{
|
||
|
// Example for: C:\WADs\Foo\Bar.WAD
|
||
|
// Created from: C:\WADs
|
||
|
// Members
|
||
|
public string filename; // bar.wad
|
||
|
public string filetitle; // bar
|
||
|
public string extension; // wad
|
||
|
public string path; // foo
|
||
|
public string filepathname; // Foo\Bar.WAD
|
||
|
public string filepathtitle; // Foo\Bar
|
||
|
|
||
|
// Constructor
|
||
|
public DirectoryFileEntry(string fullname, string frompath)
|
||
|
{
|
||
|
// Get the information we need
|
||
|
filename = Path.GetFileName(fullname);
|
||
|
filetitle = Path.GetFileNameWithoutExtension(fullname);
|
||
|
extension = Path.GetExtension(fullname);
|
||
|
if(extension.Length > 1)
|
||
|
extension = extension.Substring(1);
|
||
|
else
|
||
|
extension = "";
|
||
|
path = Path.GetDirectoryName(fullname);
|
||
|
if(path.Length > (frompath.Length + 1))
|
||
|
path = path.Substring(frompath.Length + 1);
|
||
|
else
|
||
|
path = "";
|
||
|
filepathname = Path.Combine(path, filename);
|
||
|
filepathtitle = Path.Combine(path, filetitle);
|
||
|
|
||
|
// Make some lowercase
|
||
|
filename = filename.ToLowerInvariant();
|
||
|
filetitle = filetitle.ToLowerInvariant();
|
||
|
extension = extension.ToLowerInvariant();
|
||
|
path = path.ToLowerInvariant();
|
||
|
}
|
||
|
|
||
|
// Constructor
|
||
|
public DirectoryFileEntry(string fullname)
|
||
|
{
|
||
|
// Get the information we need
|
||
|
filename = Path.GetFileName(fullname);
|
||
|
filetitle = Path.GetFileNameWithoutExtension(fullname);
|
||
|
extension = Path.GetExtension(fullname);
|
||
|
if(extension.Length > 1)
|
||
|
extension = extension.Substring(1);
|
||
|
else
|
||
|
extension = "";
|
||
|
path = Path.GetDirectoryName(fullname);
|
||
|
filepathname = Path.Combine(path, filename);
|
||
|
filepathtitle = Path.Combine(path, filetitle);
|
||
|
|
||
|
// Make some lowercase
|
||
|
filename = filename.ToLowerInvariant();
|
||
|
filetitle = filetitle.ToLowerInvariant();
|
||
|
extension = extension.ToLowerInvariant();
|
||
|
path = path.ToLowerInvariant();
|
||
|
}
|
||
|
}
|
||
|
}
|