Example #1
0
        public Collections.List Split(char splitChar)
        {
            Collections.List result = new Collections.List(1);

            int lastSplitIndex = 0;

            for (int i = 0; i < this.length; i++)
            {
                if (this[i] == splitChar)
                {
                    result.Add(this.Substring(lastSplitIndex, i - lastSplitIndex));
                    lastSplitIndex = i + 1;
                }
            }
            if (this.length - lastSplitIndex > 0)
            {
                result.Add(this.Substring(lastSplitIndex, this.length - lastSplitIndex));
            }

            return(result);
        }
Example #2
0
        public override List GetListings()
        {
            if (_cachedlistings == null)
            {
                Get_FileStream();
                byte[] data = new byte[(uint)_theFile.Size];
                _fileStream.Position = 0;
                int actuallyRead = _fileStream.Read(data, 0, (int)data.Length);
                _cachedlistings = new List(10);

                uint position = 0;
                Disk.ISO9660.DirectoryRecord newRecord;
                do
                {
                    newRecord = new Disk.ISO9660.DirectoryRecord(data, position);
#if ISO9660DIR_TRACE
                    BasicConsole.WriteLine(newRecord.ConvertToString());
#endif
                    if (newRecord.RecordLength > 0)
                    {
                        if ((newRecord.TheFileFlags & Disk.ISO9660.DirectoryRecord.FileFlags.Directory) != 0)
                        {
                            // Directory
                            _cachedlistings.Add(new ISO9660Directory((ISO9660FileSystem)TheFileSystem, this, newRecord));
                        }
                        else
                        {
                            // File
                            _cachedlistings.Add(new ISO9660File((ISO9660FileSystem)TheFileSystem, this, newRecord));
                        }

                        position += newRecord.RecordLength;
                    }
                }
                while (position < data.Length && newRecord.RecordLength > 0);
            }
            return _cachedlistings;
        }
Example #3
0
 /// <summary>
 /// Formats the specified disk.
 /// </summary>
 /// <param name="disk">The disk to format.</param>
 private void FormatDisk(Hardware.Devices.DiskDevice disk)
 {
     List newPartitionInfos = new List(1);
     
     console.WriteLine("Creating partition info...");
     newPartitionInfos.Add(FOS_System.IO.Disk.MBR.CreateFAT32PartitionInfo(disk, false));
     
     console.WriteLine("Done. Doing MBR format...");
     FOS_System.IO.Disk.MBR.FormatDisk(disk, newPartitionInfos);
     
     console.WriteLine("Done. Initialising disk...");
     FileSystemManager.InitDisk(disk);
     
     console.WriteLine("Done. Finding partition...");
     Partition thePart = null;
     for (int i = 0; i < FileSystemManager.Partitions.Count; i++)
     {
         Partition aPart = (Partition)FileSystemManager.Partitions[i];
         if(aPart.TheDiskDevice == disk)
         {
             thePart = aPart;
             break;
         }
     }
     if (thePart != null)
     {
         console.WriteLine("Done. Formatting as FAT32...");
         FOS_System.IO.FAT.FATFileSystem.FormatPartitionAsFAT32(thePart);
         
         console.WriteLine("Done.");
         console.WriteLine("Format completed successfully.");
     }
     else
     {
         console.WriteLine("Done. Partition not found.");
         console.WriteLine("Format failed.");
     }
 }
Example #4
0
        /// <summary>
        /// Splits the input string into commands including handling quoted parts.
        /// </summary>
        /// <param name="input">The input to split.</param>
        /// <returns>The list of command parts.</returns>
        private List SplitCommand(FOS_System.String input)
        {
            //This method splits the input into parts separated by spaces
            //  However, it must then also search for grouped parts which
            //  are indicated by start and end quote marks (").

            //Split the input by space
            List parts = input.Split(' ');
            //Create a list for the result - capacity 4 is the usual maximum we expect so this just
            //  optimises the internal array creation a bit.
            List result = new List(4);
            //Stores the current part being constructed.
            FOS_System.String currPart = "";
            //Indicates whether we are constructing a grouped part or not.
            bool waitingForCloseQuote = false;
            //Loop through all parts
            for(int i = 0; i < parts.Count; i++)
            {
                //If we are constructing a grouped part
                if (waitingForCloseQuote)
                {
                    //Add the part (including the space which was removed by split)
                    //  to the currently constructing part
                    currPart += " " + (FOS_System.String)parts[i];

                    //If the part ends with a quote, then we have found our closing quote
                    //  which terminates the group part
                    if(currPart.EndsWith("\""))
                    {
                        //Remove the closing quote
                        currPart = currPart.Substring(0, currPart.length - 1);
                        //End the search
                        waitingForCloseQuote = false;
                        //Add the part to the result
                        result.Add(currPart.ToLower());
                    }
                }
                else
                {
                    //Set the current part
                    currPart = (FOS_System.String)parts[i];

                    //If it starts with a quote, it is the start of a group part
                    if(currPart.StartsWith("\""))
                    {
                        //If it ends with a quote, it is also the end of the group part
                        //  so essentially the user grouped something which didn't 
                        //  actually contain any spaces.
                        if (currPart.EndsWith("\""))
                        {
                            //Remove the start and end quotes
                            currPart = currPart.Substring(1, currPart.length - 2);
                            //Add the part to the result
                            result.Add(currPart.ToLower());
                        }
                        else
                        {
                            //Remove the start quote
                            currPart = currPart.Substring(1, currPart.length - 1);
                            //Begin the search for the end of the group part
                            waitingForCloseQuote = true;
                        }
                    }
                    else
                    {
                        //This is a normal, ungrouped part so just add it to
                        //  the result
                        result.Add(currPart.ToLower());
                    }
                }
            }
            return result;
        }
Example #5
0
        /// <summary>
        /// Encodes the specified listings into a byte array.
        /// </summary>
        /// <param name="listings">The listings to encode.</param>
        /// <param name="includeVolumeID">Whether to include the Volume ID entry (partition name). Only true for root directory.</param>
        /// <returns>The encoded listings data.</returns>
        public byte[] EncodeDirectoryTable(List listings, bool includeVolumeID, UInt64 minTableSize)
        {
            int LongFilenamesSize = 0;
            for (int i = 0; i < listings.Count; i++)
            {
                if (IsLongNameListing((Base)listings[i]))
                {
                    //+1 for null terminator on long name
                    int nameLength = ((Base)listings[i]).Name.length + 1;
                    LongFilenamesSize += nameLength / 13;
                    if (nameLength % 13 > 0)
                    {
                        LongFilenamesSize++;
                    }
                }
            }
            LongFilenamesSize *= 32;

            //                       +32 for VolumeID entry                         + 32 for end entry
            byte[] result = new byte[
                Math.Max(32 + (listings.Count * 32) + LongFilenamesSize + 32, (int)minTableSize)];

            int offset = 0;

            if (includeVolumeID)
            {
                //Volume ID entry - this is only be valid for root directory.

                List shortName = GetShortName(thePartition.VolumeID, true);

                //Put in short name entry
                byte[] DIR_Name = ByteConverter.GetASCIIBytes((FOS_System.String)shortName[0]);
                byte DIR_Attr = ListingAttribs.VolumeID;
                for (int j = 0; j < DIR_Name.Length; j++)
                {
                    result[j] = DIR_Name[j];
                }
                result[DIR_Name.Length] = DIR_Attr;

                offset += 32;
            }

            for (int i = 0; i < listings.Count; i++)
            {
                Base currListing = (Base)listings[i];
                if (IsLongNameListing(currListing))
                {
                    offset = EncodeLongNameListing(currListing, result, offset);
                }

                offset = EncodeShortNameListing(currListing, result, offset);
            }


            return result;
        }
Example #6
0
        /// <summary>
        /// Parses the specified directory file data for its listings.
        /// </summary>
        /// <param name="xData">The directory data.</param>
        /// <param name="xDataLength">The directory data length.</param>
        /// <param name="thisDir">
        /// The FAT directory the FAT data is from. 
        /// Used when creating listings as the parent directory.
        /// </param>
        /// <returns>The directory listings.</returns>
        public List ParseDirectoryTable(byte[] xData, int xDataLength, FATDirectory thisDir)
        {
            List xResult = new List();

            //BasicConsole.WriteLine("Parsing listings...");

            FOS_System.String xLongName = "";
            for (UInt32 i = 0; i < xDataLength; i = i + 32)
            {
                byte xAttrib = xData[i + 11];
                if (xAttrib == ListingAttribs.LongName)
                {
                    byte xType = xData[i + 12];
                    if (xType == 0)
                    {
                        byte xOrd = xData[i];
                        if ((xOrd & 0x40) > 0)
                        {
                            xLongName = "";
                        }
                        //TODO: Check LDIR_Ord for ordering and throw exception
                        // if entries are found out of order.
                        // Also save buffer and only copy name if a end Ord marker is found.
                        FOS_System.String xLongPart = ByteConverter.GetASCIIStringFromUTF16(xData, i + 1, 5);
                        //BasicConsole.WriteLine("xLongPart1: " + xLongPart);
                        // We have to check the length because 0xFFFF is a valid Unicode codepoint.
                        // So we only want to stop if the 0xFFFF is AFTER a 0x0000. We can determine
                        // this by also looking at the length. Since we short circuit the or, the length
                        // is rarely evaluated.
                        if (xLongPart.length == 5)
                        {
                            xLongPart = xLongPart + ByteConverter.GetASCIIStringFromUTF16(xData, i + 14, 6);
                            //BasicConsole.WriteLine("xLongPart2: " + xLongPart);
                            if (xLongPart.length == 11)
                            {
                                xLongPart = xLongPart + ByteConverter.GetASCIIStringFromUTF16(xData, i + 28, 2);
                                //BasicConsole.WriteLine("xLongPart3: " + xLongPart);
                            }
                        }
                        xLongName = xLongPart + xLongName;
                        //BasicConsole.WriteLine("xLongName: " + xLongName);
                        //TODO: LDIR_Chksum 
                    }
                }
                else
                {
                    byte xStatus = xData[i];
                    if (xStatus == 0x00)
                    {
                        // Empty slot, and no more entries after this
                        break;
                    }
                    else if (xStatus == 0x05)
                    {
                        // Japanese characters - We dont handle these
                    }
                    else if (xStatus == 0xE5)
                    {
                        // Empty slot, skip it
                    }
                    else if (xStatus >= 0x20)
                    {
                        FOS_System.String xName;

                        int xTest = xAttrib & (ListingAttribs.Directory | ListingAttribs.VolumeID);

                        if (xLongName.length > 0)
                        {
                            // Leading and trailing spaces are to be ignored according to spec.
                            // Many programs (including Windows) pad trailing spaces although it 
                            // it is not required for long names.
                            xName = xLongName.Trim();

                            // As per spec, ignore trailing periods
                            //If there are trailing periods
                            int nameIndex = xName.length - 1;
                            if (xName[nameIndex] == '.')
                            {
                                //Search backwards till we find the first non-period character
                                for (; nameIndex > -1; nameIndex--)
                                {
                                    if (xName[nameIndex] != '.')
                                    {
                                        break;
                                    }
                                }
                                //Substring to remove the periods
                                xName = xName.Substring(0, nameIndex + 1);
                            }
                        }
                        else
                        {
                            FOS_System.String xEntry = ByteConverter.GetASCIIStringFromASCII(xData, i, 11);
                            //Volume ID does not have same format as file-name.
                            if (xTest == ListingAttribs.VolumeID)
                            {
                                xName = xEntry;
                            }
                            else
                            {
                                //Attempt to apply original spec:
                                // - 8 chars for filename
                                // - 3 chars for extension
                                if (xEntry.length >= 8)
                                {
                                    xName = xEntry.Substring(0, 8).TrimEnd();

                                    if (xEntry.length >= 11)
                                    {
                                        FOS_System.String xExt = xEntry.Substring(8, 3).TrimEnd();
                                        if (xExt.length > 0)
                                        {
                                            xName += "." + xExt;
                                        }
                                    }
                                }
                                else
                                {
                                    xName = xEntry;
                                }
                            }
                        }

                        UInt32 xFirstCluster = (UInt32)(ByteConverter.ToUInt16(xData, i + 20) << 16 | ByteConverter.ToUInt16(xData, i + 26));

                        xName = xName.ToUpper();

                        //TODO: Store attributes in the listings

                        if (xTest == 0)
                        {
                            if (xName[xName.length - 1] != '~')
                            {
                                UInt32 xSize = ByteConverter.ToUInt32(xData, i + 28);
                                xResult.Add(new FATFile(this, thisDir, xName, xSize, xFirstCluster));
                            }
                            else
                            {
                                //BasicConsole.WriteLine("Ignoring file: " + xName);
                            }
                        }
                        else if (xTest == ListingAttribs.VolumeID)
                        {
                            thePartition.VolumeID = xName;
                        }
                        else if (xTest == ListingAttribs.Directory)
                        {
                            xResult.Add(new FATDirectory(this, thisDir, xName, xFirstCluster));
                        }
                        xLongName = "";
                    }
                }
            }

            return xResult;
        }
Example #7
0
        /// <summary>
        /// Gets the root directory listings in the FAT file system.
        /// </summary>
        /// <returns>The root directory listings.</returns>
        public List GetRootDirectoryListings()
        {
            if (FATType == FATTypeEnum.FAT32)
            {
                if (_rootDirectoryFAT32 == null)
                {
                    _rootDirectoryFAT32 = new FATDirectory(this, null, "ROOT", RootCluster);
                }
                return _rootDirectoryFAT32.GetListings();
            }
            else
            {
                if (_rootDirectoryListings == null)
                {
                    byte[] xData = thePartition.TheDiskDevice.NewBlockArray(RootSectorCount);
                    thePartition.ReadBlock(RootSector, RootSectorCount, xData);

                    _rootDirectoryListings = ParseDirectoryTable(xData, xData.Length, null);
                }
                return _rootDirectoryListings;
            }
        }
Example #8
0
        /// <summary>
        /// Reads the directory's listings off disk unless they have already been
        /// cached.
        /// </summary>
        /// <returns>The listings.</returns>
        public override List GetListings()
        {
            if (_cachedlistings == null)
            {
#if FATDIR_TRACE
                BasicConsole.WriteLine("Getting stream...");
#endif
                Get_FileStream();
#if FATDIR_TRACE
                BasicConsole.WriteLine("Got stream. Calculating actual size...");
#endif
                ulong actualSize = _fileStream.GetActualSize();
#if FATDIR_TRACE
                BasicConsole.WriteLine(((FOS_System.String)"actualSize: ") + actualSize);
                BasicConsole.WriteLine("Creating data array...");
#endif
                byte[] xData = new byte[(uint)actualSize];
#if FATDIR_TRACE
                BasicConsole.WriteLine("Created data array.");
#endif
                _fileStream.Position = 0;
#if FATDIR_TRACE
                BasicConsole.WriteLine("Reading data...");
#endif
                int actuallyRead = _fileStream.Read(xData, 0, (int)xData.Length);
#if FATDIR_TRACE
                BasicConsole.WriteLine("Read data. Parsing table...");
#endif
                _cachedlistings = ((FATFileSystem)TheFileSystem).ParseDirectoryTable(xData, actuallyRead, this);
#if FATDIR_TRACE
                BasicConsole.WriteLine("Parsed table.");
#endif
            }
            return _cachedlistings;
        }
Example #9
0
        public Collections.List Split(char splitChar)
        {
            Collections.List result = new Collections.List(1);

            int lastSplitIndex = 0;
            for (int i = 0; i < this.length; i++)
            {
                if (this[i] == splitChar)
                {
                    result.Add(this.Substring(lastSplitIndex, i - lastSplitIndex));
                    lastSplitIndex = i + 1;
                }
            }
            if (this.length - lastSplitIndex > 0)
            {
                result.Add(this.Substring(lastSplitIndex, this.length - lastSplitIndex));
            }

            return result;
        }
Example #10
0
 /// <summary>
 /// Determines whether the specified listing exists or not within this directory or its sub-directories.
 /// </summary>
 /// <param name="name">The full path and name of the listing to check for.</param>
 /// <param name="listings">The list of listings to search through.</param>
 /// <returns>Whether the listing exists or not.</returns>
 public static bool ListingExists(FOS_System.String name, List listings)
 {
     for (int i = 0; i < listings.Count; i++)
     {
         if (((Base)listings[i]).Name == name)
         {
             return true;
         }
     }
     return false;
 }
Example #11
0
 public Stack(int capacity)
 {
     internalList = new List(capacity);
 }
Example #12
0
 public PriorityQueue(int InitialCapacity)
 {
     ImplicitHeap = new List(InitialCapacity);
 }
Example #13
0
        public static void Main()
        {
            BasicConsole.WriteLine("Window Manager: Started.");

            // Initialise heap & GC
            Hardware.Processes.ProcessManager.CurrentProcess.InitHeap();
            
            // Start thread for calling GC Cleanup method
            if (SystemCalls.StartThread(GCCleanupTask.Main, out GCThreadId) != SystemCallResults.OK)
            {
                BasicConsole.WriteLine("Window Manager: GC thread failed to create!");
            }

            // Initialise connected pipes list
            ConnectedPipes = new List();

            // Start thread for handling background input processing
            if (SystemCalls.StartThread(InputProcessing, out InputProcessingThreadId) != SystemCallResults.OK)
            {
                BasicConsole.WriteLine("Window Manager: InputProcessing thread failed to create!");
            }

            BasicConsole.Write("WM > InputProcessing thread id: ");
            BasicConsole.WriteLine(InputProcessingThreadId);

            BasicConsole.Write("WM > Register RegisterPipeOutpoint syscall handler");
            SystemCalls.RegisterSyscallHandler(SystemCallNumbers.RegisterPipeOutpoint, SyscallHandler);


            // Start thread for handling background output processing
            if (SystemCalls.StartThread(OutputProcessing, out OutputProcessingThreadId) != SystemCallResults.OK)
            {
                BasicConsole.WriteLine("Window Manager: OutputProcessing thread failed to create!");
            }

            BasicConsole.WriteLine("WM > Init keyboard");
            Keyboard.InitDefault();
            BasicConsole.WriteLine("WM > Register IRQ 1 handler");
            SystemCalls.RegisterIRQHandler(1, HandleIRQ);

            BasicConsole.WriteLine("WM > Wait for pipe to be created");
            // Wait for pipe to be created
            ready_count++;
            SystemCalls.SleepThread(SystemCalls.IndefiniteSleepThread);

            PipeInfo CurrentPipeInfo = null;

            while (!Terminating)
            {
                try
                {
                    if (CurrentPipeIdx > -1)
                    {
                        if (CurrentPipeIndex_Changed)
                        {
                            CurrentPipeInfo = ((PipeInfo)ConnectedPipes[CurrentPipeIdx]);
                            CurrentPipeIndex_Changed = false;

                            CurrentPipeInfo.TheConsole.Update();
                        }

                        CurrentPipeInfo.TheConsole.Write(CurrentPipeInfo.StdOut.Read(false));
                    }
                }
                catch
                {
                    if (ExceptionMethods.CurrentException is Pipes.Exceptions.RWFailedException)
                    {
                        //SystemCalls.SleepThread(100);
                    }
                    else
                    {
                        BasicConsole.WriteLine("WM > Exception running window manager.");
                        BasicConsole.WriteLine(ExceptionMethods.CurrentException.Message);
                    }
                }
            }
        }
Example #14
0
        /// <summary>
        /// Formats the specified using the specified partition informations.
        /// </summary>
        /// <param name="aDisk">The disk to format.</param>
        /// <param name="partitionInfos">The partition informations to use for the format.</param>
        public static void FormatDisk(Hardware.Devices.DiskDevice aDisk, List partitionInfos)
        {
            //Necessary to remove any trace of GPT:
            //  Overwrite first 256 sectors with 0s (should do the trick)
            aDisk.WriteBlock(0UL, 256U, null);

#if MBR_TRACE
            BasicConsole.WriteLine("Creating new MBR data...");
#endif
            byte[] newMBRData = new byte[512];

            newMBRData[0x1FE] = 0x55;
            newMBRData[0x1FF] = 0xAA;

#if MBR_TRACE
            BasicConsole.WriteLine(((FOS_System.String)"Set signature: ") + newMBRData[0x1FE] + " " + newMBRData[0x1FF]);
            BasicConsole.DelayOutput(1);

            BasicConsole.WriteLine(((FOS_System.String)"Num new partitions: ") + partitionInfos.Count);
            BasicConsole.DelayOutput(1);
#endif

            uint part1Offset = 0x1BE;
            for (uint i = 0; i < partitionInfos.Count; i++)
            {
                PartitionInfo partInfo = (PartitionInfo)partitionInfos[(int)i];
                uint partOffset = part1Offset + (0x10 * i);
#if MBR_TRACE
                BasicConsole.WriteLine(((FOS_System.String)"Partition ") + i + " @ " + partOffset);
                BasicConsole.WriteLine(((FOS_System.String)"Bootable : ") + partInfo.Bootable);
                BasicConsole.WriteLine(((FOS_System.String)"SystemID : ") + partInfo.SystemID);
                BasicConsole.WriteLine(((FOS_System.String)"StartSector : ") + partInfo.StartSector);
                BasicConsole.WriteLine(((FOS_System.String)"SectorCount : ") + partInfo.SectorCount);
                BasicConsole.DelayOutput(2);
#endif

                //Bootable / active
                newMBRData[partOffset + 0] = (byte)(partInfo.Bootable ? 0x81 : 0x00);
                //System ID
                newMBRData[partOffset + 4] = partInfo.SystemID;
                //Start sector
                newMBRData[partOffset + 8] = (byte)(partInfo.StartSector);
                newMBRData[partOffset + 9] = (byte)(partInfo.StartSector >> 8);
                newMBRData[partOffset + 10] = (byte)(partInfo.StartSector >> 16);
                newMBRData[partOffset + 11] = (byte)(partInfo.StartSector >> 24);
                //Sector count
                newMBRData[partOffset + 12] = (byte)(partInfo.SectorCount);
                newMBRData[partOffset + 13] = (byte)(partInfo.SectorCount >> 8);
                newMBRData[partOffset + 14] = (byte)(partInfo.SectorCount >> 16);
                newMBRData[partOffset + 15] = (byte)(partInfo.SectorCount >> 24);
   
#if MBR_TRACE
                BasicConsole.WriteLine("Reading back data...");
                byte bootable = newMBRData[partOffset + 0];
                byte systemID = newMBRData[partOffset + 4];
                UInt32 startSector = ByteConverter.ToUInt32(newMBRData, partOffset + 8);
                UInt32 sectorCount = ByteConverter.ToUInt32(newMBRData, partOffset + 12);
                BasicConsole.WriteLine(((FOS_System.String)"Bootable : ") + bootable);
                BasicConsole.WriteLine(((FOS_System.String)"SystemID : ") + systemID);
                BasicConsole.WriteLine(((FOS_System.String)"StartSector : ") + startSector);
                BasicConsole.WriteLine(((FOS_System.String)"SectorCount : ") + sectorCount);
                BasicConsole.DelayOutput(2);
#endif
            }
            
#if MBR_TRACE
            BasicConsole.WriteLine("Writing data...");
#endif
            aDisk.WriteBlock(0UL, 1U, newMBRData);
#if MBR_TRACE
            BasicConsole.WriteLine("Data written.");
            BasicConsole.DelayOutput(1);
#endif
            aDisk.CleanCaches();
        }
Example #15
0
        /// <summary>
        /// Gets a specific listing from the specified list of listings. Performs a recursive
        /// search down the file system tree.
        /// </summary>
        /// <param name="nameParts">The parts of the full path of the listing to get.</param>
        /// <param name="parent">The parent directory of the directory from which the listings were taken.</param>
        /// <param name="listings">The listings to search through.</param>
        /// <returns>The listing or null if not found.</returns>
        public Base GetListingFromListings(List nameParts, Directory parent, List listings)
        {
            //  ".." means "parent directory"
            if (((FOS_System.String)nameParts[0]) == "..")
            {
                nameParts.RemoveAt(0);
                if (nameParts.Count == 0)
                {
                    return parent;
                }

                return parent.GetListing(nameParts);
            }

            for (int i = 0; i < listings.Count; i++)
            {
                Base aListing = (Base)listings[i];
                if (aListing.Name == (FOS_System.String)nameParts[0])
                {
                    nameParts.RemoveAt(0);
                    if (nameParts.Count == 0)
                    {
                        return aListing;
                    }
                    else if (aListing.IsDirectory)
                    {
                        return ((Directory)aListing).GetListing(nameParts);
                    }
                }
            }

            return null;
        }
Example #16
0
 /// <summary>
 /// Replaces the keyboard mapping with the one specified.
 /// </summary>
 /// <param name="aKeys">The new keyboard mapping to use.</param>
 public void ChangeKeyMap(List aKeys)
 {
     KeyMappings = aKeys;
 }
Example #17
0
 /// <summary>
 /// Gets the short name for the specified long name.
 /// </summary>
 /// <param name="longName">The long name to shorten.</param>
 /// <param name="isDirectory">Whether the long name is for a directory or not.</param>
 /// <returns>The short name parts. Directory=1 part, file=2 parts (name + extension).</returns>
 private static List GetShortName(FOS_System.String longName, bool isDirectory)
 {
     if (isDirectory)
     {
         List result = new List(1);
         result.Add(longName.Substring(0, 8).PadRight(11, ' '));
         return result;
     }
     else
     {
         List result = new List(2);
         List nameParts = longName.Split('.');
         if (nameParts.Count > 1)
         {
             result.Add(((FOS_System.String)nameParts[0]).Substring(0, 8).PadRight(8, ' '));
             result.Add(((FOS_System.String)nameParts[1]).Substring(0, 3).PadRight(3, ' '));
         }
         else
         {
             result.Add(longName.Substring(0, 8).PadRight(8, ' '));
             result.Add(((FOS_System.String)"").PadRight(3, ' '));
         }
         return result;
     }
 }
Example #18
0
        /// <summary>
        /// Creates the US keyboard mapping
        /// </summary>
        protected void CreateUSKeymap()
        {
            //  This creates (most/some of) a US keyboard mapping.
            //  You can go look up scancodes / characters etc. for other
            //  keyboards if you like.
            BasicConsole.WriteLine("Using US Keyboard layout.");
            //BasicConsole.DelayOutput(3);
            KeyMappings = new List(164);

            //TODO: fn key
            //TODO: full numpad?
            //TODO: Other UK keys e.g. backslash

            #region Letters
            AddKey(0x10, 'q', KeyboardKey.Q);
            AddKey(0x100000, 'Q', KeyboardKey.Q);
            AddKey(0x11, 'w', KeyboardKey.W);
            AddKey(0x110000, 'W', KeyboardKey.W);
            AddKey(0x12, 'e', KeyboardKey.E);
            AddKey(0x120000, 'E', KeyboardKey.E);
            AddKey(0x13, 'r', KeyboardKey.R);
            AddKey(0x130000, 'R', KeyboardKey.R);
            AddKey(0x14, 't', KeyboardKey.T);
            AddKey(0x140000, 'T', KeyboardKey.T);
            AddKey(0x15, 'y', KeyboardKey.Y);
            AddKey(0x150000, 'Y', KeyboardKey.Y);
            AddKey(0x16, 'u', KeyboardKey.U);
            AddKey(0x160000, 'U', KeyboardKey.U);
            AddKey(0x17, 'i', KeyboardKey.I);
            AddKey(0x170000, 'I', KeyboardKey.I);
            AddKey(0x18, 'o', KeyboardKey.O);
            AddKey(0x180000, 'O', KeyboardKey.O);
            AddKey(0x19, 'p', KeyboardKey.P);
            AddKey(0x190000, 'P', KeyboardKey.P);

            AddKey(0x1E, 'a', KeyboardKey.A);
            AddKey(0x1E0000, 'A', KeyboardKey.A);
            AddKey(0x1F, 's', KeyboardKey.S);
            AddKey(0x1F0000, 'S', KeyboardKey.S);
            AddKey(0x20, 'd', KeyboardKey.D);
            AddKey(0x200000, 'D', KeyboardKey.D);
            AddKey(0x21, 'f', KeyboardKey.F);
            AddKey(0x210000, 'F', KeyboardKey.F);
            AddKey(0x22, 'g', KeyboardKey.G);
            AddKey(0x220000, 'G', KeyboardKey.G);
            AddKey(0x23, 'h', KeyboardKey.H);
            AddKey(0x230000, 'H', KeyboardKey.H);
            AddKey(0x24, 'j', KeyboardKey.J);
            AddKey(0x240000, 'J', KeyboardKey.J);
            AddKey(0x25, 'k', KeyboardKey.K);
            AddKey(0x250000, 'K', KeyboardKey.K);
            AddKey(0x26, 'l', KeyboardKey.L);
            AddKey(0x260000, 'L', KeyboardKey.L);

            AddKey(0x2C, 'z', KeyboardKey.Z);
            AddKey(0x2C0000, 'Z', KeyboardKey.Z);
            AddKey(0x2D, 'x', KeyboardKey.X);
            AddKey(0x2D0000, 'X', KeyboardKey.X);
            AddKey(0x2E, 'c', KeyboardKey.C);
            AddKey(0x2E0000, 'C', KeyboardKey.C);
            AddKey(0x2F, 'v', KeyboardKey.V);
            AddKey(0x2F0000, 'V', KeyboardKey.V);
            AddKey(0x30, 'b', KeyboardKey.B);
            AddKey(0x300000, 'B', KeyboardKey.B);
            AddKey(0x31, 'n', KeyboardKey.N);
            AddKey(0x310000, 'N', KeyboardKey.N);
            AddKey(0x32, 'm', KeyboardKey.M);
            AddKey(0x320000, 'M', KeyboardKey.M);
            #endregion

            #region digits
            AddKey(0x29, '`', KeyboardKey.NoName);
            AddKey(0x290000, (char)170u, KeyboardKey.NoName);
            AddKey(0x2, '1', KeyboardKey.D1);
            AddKey(0x20000, '!', KeyboardKey.D1);
            AddKey(0x3, '2', KeyboardKey.D2);
            AddKey(0x30000, '@', KeyboardKey.D2);
            AddKey(0x4, '3', KeyboardKey.D3);
            AddKey(0x40000, '#', KeyboardKey.D3);
            AddKey(0x5, '4', KeyboardKey.D4);
            AddKey(0x50000, '$', KeyboardKey.D5);
            AddKey(0x6, '5', KeyboardKey.D5);
            AddKey(0x60000, '%', KeyboardKey.D5);
            AddKey(0x7, '6', KeyboardKey.D6);
            AddKey(0x70000, '^', KeyboardKey.D6);
            AddKey(0x8, '7', KeyboardKey.D7);
            AddKey(0x80000, '&', KeyboardKey.D7);
            AddKey(0x9, '8', KeyboardKey.D8);
            AddKey(0x90000, '*', KeyboardKey.D8);
            AddKey(0xA, '9', KeyboardKey.D9);
            AddKey(0xA0000, '(', KeyboardKey.D9);
            AddKey(0xB, '0', KeyboardKey.D0);
            AddKey(0xB0000, ')', KeyboardKey.D0);

            #endregion

            #region Special
            AddKeyWithAndWithoutShift(0x0E, '\0', KeyboardKey.Backspace);               //Backspace
            AddKeyWithAndWithoutShift(0x0F, '\t', KeyboardKey.Tab);                         //Tabulator
            AddKeyWithAndWithoutShift(0x1C, '\n', KeyboardKey.Enter);                       //Enter
            AddKeyWithAndWithoutShift(0x39, ' ', KeyboardKey.Spacebar);                     //Space
            AddKeyWithAndWithoutShift(0x4b, '\u2190', KeyboardKey.LeftArrow);               //Left arrow
            AddKeyWithAndWithoutShift(0x48, '\u2191', KeyboardKey.UpArrow);                 //Up arrow
            AddKeyWithAndWithoutShift(0x4d, '\u2192', KeyboardKey.RightArrow);              //Right arrow
            AddKeyWithAndWithoutShift(0x50, '\u2193', KeyboardKey.DownArrow);               //Down arrow

            AddKeyWithShift(0x5b, KeyboardKey.LeftWindows);
            AddKeyWithShift(0x5c, KeyboardKey.RightWindows);
            //AddKey(0x5d, KeyboardKey.NoName);                                   //Context Menu  

            AddKeyWithShift(0x52, KeyboardKey.Insert);
            AddKeyWithShift(0x47, KeyboardKey.Home);
            AddKeyWithShift(0x49, KeyboardKey.PageUp);
            AddKeyWithShift(0x53, KeyboardKey.Delete);
            AddKeyWithShift(0x4f, KeyboardKey.End);
            AddKeyWithShift(0x51, KeyboardKey.PageDown);

            AddKeyWithShift(0x37, KeyboardKey.PrintScreen);
            //AddKeyWithShift(0x46, KeyboardKey.NoName);                          //Scroll Lock
            //AddKeyWithShift(0x3a, KeyboardKey.NoName);                          //Caps Lock
            AddKeyWithShift(0x45, KeyboardKey.Pause);

            AddKeyWithShift(0x3b, KeyboardKey.F1);
            AddKeyWithShift(0x3c, KeyboardKey.F2);
            AddKeyWithShift(0x3d, KeyboardKey.F3);
            AddKeyWithShift(0x3e, KeyboardKey.F4);
            AddKeyWithShift(0x3f, KeyboardKey.F5);
            AddKeyWithShift(0x40, KeyboardKey.F6);
            AddKeyWithShift(0x41, KeyboardKey.F7);
            AddKeyWithShift(0x42, KeyboardKey.F8);
            AddKeyWithShift(0x43, KeyboardKey.F9);
            AddKeyWithShift(0x44, KeyboardKey.F10);
            AddKeyWithShift(0x57, KeyboardKey.F11);
            AddKeyWithShift(0x58, KeyboardKey.F12);

            AddKeyWithShift(0x1, KeyboardKey.Escape);
            #endregion

            #region Punctuation and Signs
            AddKey(0x27, ';', KeyboardKey.NoName);
            AddKey(0x270000, ':', KeyboardKey.NoName);
            AddKey(0x2B, '\\', KeyboardKey.NoName);
            AddKey(0x2B0000, '|', KeyboardKey.NoName);
            AddKey(0x29, '`', KeyboardKey.NoName);
            AddKey(0x290000, '~', KeyboardKey.NoName);
            AddKey(0x33, ',', KeyboardKey.OemComma);
            AddKey(0x330000, '<', KeyboardKey.OemComma);
            AddKey(0x34, '.', KeyboardKey.OemPeriod);
            AddKey(0x340000, '>', KeyboardKey.OemPeriod);
            AddKey(0x35, '/', KeyboardKey.Divide);
            AddKey(0x350000, '?', KeyboardKey.Divide);
            AddKey(0x0C, '-', KeyboardKey.Subtract);
            AddKey(0x0C0000, '_', KeyboardKey.Subtract);
            AddKey(0x0D, '=', KeyboardKey.OemPlus);
            AddKey(0x0D0000, '+', KeyboardKey.OemPlus);
            AddKey(0x1A, '[', KeyboardKey.NoName);
            AddKey(0x1A0000, '{', KeyboardKey.NoName);
            AddKey(0x1B, ']', KeyboardKey.NoName);
            AddKey(0x1B0000, '}', KeyboardKey.NoName);

            AddKeyWithAndWithoutShift(0x4c, '5', KeyboardKey.NumPad5);

            AddKeyWithAndWithoutShift(0x4a, '-', KeyboardKey.OemMinus);
            AddKeyWithAndWithoutShift(0x4e, '+', KeyboardKey.OemPlus);

            AddKeyWithAndWithoutShift(0x37, '*', KeyboardKey.Multiply);
            #endregion
        }
Example #19
0
 /// <summary>
 /// Gets the listing for the specified path.
 /// </summary>
 /// <param name="nameParts">The path to the listing.</param>
 /// <returns>The listing or null if not found.</returns>
 public override Base GetListing(List nameParts)
 {
     return TheFileSystem.GetListingFromListings(nameParts, Parent, GetListings());
 }