Inheritance: MonoBehaviour
Ejemplo n.º 1
0
        /// <summary>
        /// Functionality provided by mainboard to mount storage devices, given the volume name of the storage device (see <see cref="GetStorageDeviceVolumeNames"/>).
        /// This should result in a <see cref="Microsoft.SPOT.IO.RemovableMedia.Insert"/> event if successful.
        /// </summary>
        public override bool MountStorageDevice(string volumeName)
        {
            this.storage = new PersistentStorage(volumeName);
            this.storage.MountFileSystem();

            return(true);
        }
Ejemplo n.º 2
0
        public static string CreateMtmDelete(PropertyDescription pd, PersistentStorage ps, IList <EntityBase> entities)
        {
            RelationAttribute attr = pd.GetAttribute <RelationAttribute>();

            if (attr == null || attr.RelationType != RelationType.ManyToMany)
            {
                throw new Exception("A many-to-many relationship expected");
            }
            string script = "DELETE FROM " + (string.IsNullOrEmpty(attr.SchemaName) ? "" : attr.SchemaName + ".") +
                            attr.MamyToManyRelationTable + "\r\nWHERE ";

            script += attr.MtmRelationTableParentColumn + " IN (";
            string data = "";

            foreach (EntityBase entity in entities)
            {
                if (string.IsNullOrEmpty(data))
                {
                    data = ValueToString(entity.ID);
                }
                else
                {
                    data += ", " + ValueToString(entity.ID);
                }
            }
            script += data + ")\r\n";
            return(script);
        }
        public void WriteCreatesMissingParentFolders()
        {
            //Arrange

            string testText     = "hello, world!\n";
            string testFilename =
                Unique("Write/Creates/Missing/Parent/Folders.txt");

            // create the file

            PersistentStorage.Write(testFilename, testText);


            //Act

            // does the file exist?

            bool actualExistence = FileExists(testFilename);


            //Assert

            // the file should have existed

            Assert.IsTrue(actualExistence);
        }
 public void StoreParameters(PersistentStorage destination)
 {
     destination.Store(
         _directory,
         _displayAll,
         _recursive);
 }
Ejemplo n.º 5
0
 static void Main()
 {
     // ... check if SD is inserted
     // SD Card is inserted
     // Create a new storage device
     PersistentStorage sdPS = new PersistentStorage("SD");
     // Mount the file system
     sdPS.MountFileSystem();
     // Assume one storage device is available,
     // access it through NETMF
     string rootDirectory = VolumeInfo.GetVolumes()[0].RootDirectory;
     FileStream FileHandle = new FileStream(rootDirectory + @"\hello1.txt", FileMode.Create);
     byte[] data = Encoding.UTF8.GetBytes("This string will go in the file!");
       // Toggle LED on SD Write
     OutputPort LED;
     LED = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, true);
     LED.Write(true);
     // write the data and close the file
     FileHandle.Write(data, 0, data.Length);
       FileHandle.Close();
     // Turn off led
     LED.Write(false);
     // if we need to unmount
     sdPS.UnmountFileSystem();
     // ...
     Thread.Sleep(100);
 }
Ejemplo n.º 6
0
 void Awake()
 {
     storage  = new PersistentStorage();
     objects  = new List <PersistableObject>();
     savePath = Path.Combine(Application.persistentDataPath, "saveFile");
     Debug.Log("Save path: " + savePath);
 }
Ejemplo n.º 7
0
 public XmlDataLoader(XmlReader reader, PersistentStorage ps, Type type)
 {
     _type         = type;
     _ps           = ps;
     _sourceReader = reader;
     _mapper       = new Mapper(type, ps);
 }
        public void WriteToExistingFilenameShouldOverwrite()
        {
            //Arrange

            string testText1 =
                "Write Then Read Back Should Give Same String Text 1";
            string testText2    = "Not the same as the first text";
            string testFilename =
                Unique("WriteToExistingFilenameShouldOverwrite.txt");


            //Act

            // try to write first string to filename

            PersistentStorage.Write(testFilename, testText1);

            // then overrite it with second string to same filename

            PersistentStorage.Write(testFilename, testText2);

            // try to read it back from the same file

            string actualText = PersistentStorage.Read(testFilename);


            //Assert

            // the read text should be the second string

            Assert.AreEqual(testText2, actualText);
        }
Ejemplo n.º 9
0
 private void UpdateBestScore(int bestScore)
 {
     if (PersistentStorage.LoadData() < bestScore)
     {
         PersistentStorage.SaveData(bestScore);
     }
 }
        public void MixedPathSeparatorsAreHandled()
        {
            //Arrange

            string testText     = "hello, world!\n";
            string testFilename =
                Unique("Mixed\\Path/Separators\\Are/Handled.txt");

            // create the file

            PersistentStorage.Write(testFilename, testText);


            //Act

            // does the file exist?

            bool actualExistence = FileExists(testFilename);


            //Assert

            // the file should have existed

            Assert.IsTrue(actualExistence);
        }
        public void ListingWithPatternsWorksWithRecursionOn()
        {
            //Arrange

            PersistentStorage.Write(Unique("A.ignore"), "");
            PersistentStorage.Write(Unique("A.return"), "");
            PersistentStorage.Write(Unique("A2.ignore"), "");
            PersistentStorage.Write(Unique("A2.return"), "");
            PersistentStorage.Write(Unique("sub/B.ignore"), "");
            PersistentStorage.Write(Unique("sub/B.return"), "");
            PersistentStorage.Write(Unique("sub/B2.ignore"), "");
            PersistentStorage.Write(Unique("sub/B2.return"), "");
            PersistentStorage.Write(Unique("sub/sub/C.ignore"), "");
            PersistentStorage.Write(Unique("sub/sub/C.return"), "");
            PersistentStorage.Write(Unique("sub/sub/C2.ignore"), "");
            PersistentStorage.Write(Unique("sub/sub/C2.return"), "");


            //Act

            string[] results = PersistentStorage.ListFiles(Unique(""), true, "*.return");


            //Assert

            CollectionAssert.AreEquivalent(
                new string[] {
                "A.return",
                "A2.return",
                PathJoin("sub", "B.return"),
                PathJoin("sub", "B2.return"),
                PathJoin("sub", "sub", "C.return"),
                PathJoin("sub", "sub", "C2.return")
            }, results);
        }
        public void WriteThenReadBackShouldGiveSameString()
        {
            //Arrange

            string testText =
                "Write Then Read Back Should Give Same String Text";
            string testFilename =
                Unique("WriteThenReadBackShouldGiveSameStringFilename.txt");


            //Act

            // try to write this string to filename

            PersistentStorage.Write(testFilename, testText);

            // try to read it back from the same file

            string actualText = PersistentStorage.Read(testFilename);


            //Assert

            // the text read is the same as what we wrote

            Assert.AreEqual(testText, actualText);
        }
        public void DeletingANonExistingFileDoesntCauseAnError()
        {
            //Arrange

            string testText     = "hello, world!\n";
            string testFilename =
                Unique("DeletingANonExistingFileDoesntCauseAnError.txt");

            // create the file

            PersistentStorage.Write(testFilename, testText);


            //Act

            // delete the file multiple times

            PersistentStorage.Delete(testFilename);
            PersistentStorage.Delete(testFilename);
            PersistentStorage.Delete(testFilename);


            //Assert

            // If execution reaches this point, no error occured.

            Assert.Pass();
        }
        public void WhenListingEndingSlashShouldNotAffectResults()
        {
            //Arrange

            PersistentStorage.Write(Unique("subfolder/A"), "");
            PersistentStorage.Write(Unique("subfolder/B"), "");
            PersistentStorage.Write(Unique("subfolder/C"), "");


            //Act

            string[] results1 = PersistentStorage.ListFiles(Unique("subfolder"));
            string[] results2 = PersistentStorage.ListFiles(Unique("subfolder/"));
            string[] results3 = PersistentStorage.ListFiles(Unique("subfolder\\"));


            //Assert

            // the files A, B and C should be returned in each case

            string[] expected = new string[] { "A", "B", "C" };
            CollectionAssert.AreEquivalent(expected, results1);
            CollectionAssert.AreEquivalent(expected, results2);
            CollectionAssert.AreEquivalent(expected, results3);
        }
Ejemplo n.º 15
0
 // Use this for initialization
 void Start()
 {
     PersistentStorage.init();
     timelineSlider.maxValue = PersistentStorage.list.Count;
     timelineSlider.value    = timelineSlider.maxValue;
     Debug.LogFormat("Found {0} video players", timelineSlider.maxValue);
 }
        public IActionResult Notify(string message, string client)
        {
            if (client == null)
            {
                return(BadRequest("No Client Name parsed."));
            }
            PushSubscription subscription = PersistentStorage.GetSubscription(client);

            if (subscription == null)
            {
                return(BadRequest("Client was not found"));
            }

            var subject    = configuration["VAPID:subject"];
            var publicKey  = configuration["VAPID:publicKey"];
            var privateKey = configuration["VAPID:privateKey"];

            var vapidDetails = new VapidDetails(subject, publicKey, privateKey);

            var webPushClient = new WebPushClient();

            try
            {
                webPushClient.SendNotification(subscription, message, vapidDetails);
            }
            catch (Exception exception)
            {
            }

            return(View(PersistentStorage.GetClientNames()));
        }
        public void WriteIncludingNewlinesShouldAllReadInOneGo()
        {
            //Arrange

            string testText =
                "This \n Text\n  Contains\n Newlines!\n";
            string testFilename =
                Unique("WriteIncludingNewlinesShouldAllReadInOneGo.txt");


            //Act

            // try and write the multi-line string to file

            PersistentStorage.Write(testFilename, testText);

            // try to read it back from the same file

            string actualText = PersistentStorage.Read(testFilename);


            //Assert

            // the read text should be the whole string incl newlines

            Assert.AreEqual(testText, actualText);
        }
Ejemplo n.º 18
0
 public static void Main()
 {
     // ...
     // SD Card is inserted
     // Create a new storage device
     PersistentStorage sdPS = new PersistentStorage("SD");
     // Mount the file system
     sdPS.MountFileSystem();
     // Assume one storage device is available, access it through
     // Micro Framework and display available files and folders:
     Debug.Print("Getting files and folders:");
     if (VolumeInfo.GetVolumes()[0].IsFormatted)
     {
     string rootDirectory =
     VolumeInfo.GetVolumes()[0].RootDirectory;
     string[] files = Directory.GetFiles(rootDirectory);
     string[] folders = Directory.GetDirectories(rootDirectory);
     Debug.Print("Files available on " + rootDirectory + ":");
     for (int i = 0; i < files.Length; i++)
     Debug.Print(files[i]);
     Debug.Print("Folders available on " + rootDirectory + ":");
     for (int i = 0; i < folders.Length; i++)
     Debug.Print(folders[i]);
     }
     else
     {
     Debug.Print("Storage is not formatted. Format on PC with FAT32/FAT16 first.");
     }
     // Unmount
     sdPS.UnmountFileSystem();
 }
Ejemplo n.º 19
0
    void Start()
    {
        virtualButton.GetComponent <VirtualButtonBehaviour>().RegisterEventHandler(this);
        PersistentStorage.init();
#if !UNITY_EDITOR
        initHelper();
#endif
    }
Ejemplo n.º 20
0
 public MsSqlDataLoader(PersistentStorage ps, string connectionString, Type type)
 {
     _type             = type;
     _mapper           = new Mapper(type, ps);
     _connectionString = connectionString;
     _ps = ps;
     //_connection = new SqlConnection(connectionString);
 }
Ejemplo n.º 21
0
        /// <summary>
        /// Functionality provided by mainboard to mount storage devices, given the volume name of the storage device (see <see cref="GetStorageDeviceVolumeNames"/>).
        /// This should result in a Microsoft.SPOT.IO.RemovableMedia.Insert event if successful.
        /// </summary>
        public override bool MountStorageDevice(string volumeName)
        {
            // implement this if you support storage devices. This should result in a <see cref="Microsoft.SPOT.IO.RemovableMedia.Insert"/> event if successful and return true if the volumeName is supported.
            _storage = new PersistentStorage(volumeName);
            _storage.MountFileSystem();

            return(true);// volumeName == "SD";
        }
Ejemplo n.º 22
0
        static void EnableSD()
        {
            _hdd = new PersistentStorage("SD");
            _hdd.MountFileSystem();

            _root   = "\\SD\\";
            _curDir = "\\SD\\";
        }
Ejemplo n.º 23
0
 public void Dispose()
 {
     if (storageType == FileBrowser.StorageType.SD && storage != null)
     {
         storage.Dispose();
         storage = null;
     }
 }
Ejemplo n.º 24
0
 public void Dispose()
 {
     if (storageType == FileBrowser.StorageType.SD && storage != null)
     {
         storage.Dispose();
         storage = null;
     }
 }
Ejemplo n.º 25
0
 void USBHostController_DeviceConnectedEvent(USBH_Device device)
 {
     if (device.TYPE == USBH_DeviceType.MassStorage)
     {
         PersistentStorage usbStorage = new PersistentStorage(device);
         usbStorage.MountFileSystem();
         _usbStorages.Add(device.ID, usbStorage);
     }
 }
Ejemplo n.º 26
0
Archivo: Room.cs Proyecto: habb0/IHI-1
        protected Room(int id)
        {
            Id = id;
            Description = String.Empty;
            Capacity = 25;

            _roomUnits = new HashSet<IRoomUnit>();
            _persistentStorage = new PersistentStorage(this);
        }
Ejemplo n.º 27
0
 public SqlScriptBuilder(Mapper mapper, PersistentStorage ps)
 {
     _ps                    = ps;
     _mapper                = mapper;
     _insertTemplate        = _insertTemplate.Replace("@@TableName", mapper.FullTableName);
     _updateTemplate        = _updateTemplate.Replace("@@TableName", mapper.FullTableName);
     _updateInBatchTemplate = _updateInBatchTemplate.Replace("@@TableName", mapper.FullTableName);
     _deleteTemplate        = _deleteTemplate.Replace("@@TableName", mapper.FullTableName);
 }
Ejemplo n.º 28
0
 public static void Load()
 {
     if (PersistentStorage.DetectSDCard())
     {
         storage = new PersistentStorage("SD");
         storage.MountFileSystem();
         RemovableMedia.Insert += new InsertEventHandler(RemovableMedia_Insert);
     }
 }
        public void DeleteArchiveData(int index)
        {
            ArchivePreviewData previewData = ArchivePreviewData.ArchivePreviewData[index];

            PersistentStorage.Delete(GetArchiveName(previewData));
            ArchivePreviewData.ArchivePreviewData.Remove(previewData);
            Data.LocalCacheManager.SetData(ArchivePreviewData);
            SortArchivePreViewData();
        }
Ejemplo n.º 30
0
        protected Room(int id)
        {
            Id          = id;
            Description = String.Empty;
            Capacity    = 25;

            _roomUnits         = new HashSet <IRoomUnit>();
            _persistentStorage = new PersistentStorage(this);
        }
 void USBHostController_DeviceConnectedEvent(USBH_Device device)
 {
     if (device.TYPE == USBH_DeviceType.MassStorage)
     {
         PersistentStorage usbStorage = new PersistentStorage(device);
         usbStorage.MountFileSystem();
         _usbStorages.Add(device.ID, usbStorage);
     }
 }
Ejemplo n.º 32
0
        private static void SetupStorage()
        {
            Trace.TraceInformation("Setting up storage...");

            storage = new PersistentStorage(SDCardVolumeName);
            storage.MountFileSystem();

            Trace.OpenTrace();
        }
Ejemplo n.º 33
0
 void USBHostController_DeviceDisconnectedEvent(USBH_Device device)
 {
     if (device.TYPE == USBH_DeviceType.MassStorage && _usbStorages.Contains(device.ID))
     {
         PersistentStorage usbStorage = (PersistentStorage)_usbStorages[device.ID];
         usbStorage.UnmountFileSystem();
         usbStorage.Dispose();
         _usbStorages.Remove(device.ID);
     }
 }
Ejemplo n.º 34
0
 private ExceptionService()
 {
     this.Device = new PersistentStorage("SD");
     this.Device.MountFileSystem();
     this.Volume = VolumeInfo.GetVolumes()[0];
     if (this.Volume == null)
     {
         throw new ApplicationException("Unable to get SD card VolumeInfo object.");
     }
 }
Ejemplo n.º 35
0
        public static void Test()
        {

            // Create new Thread that runs the ExampleThreadFunction
            Thread ExampleThread = new Thread(new ThreadStart(ExampleThreadFunction));

            // SD stuff is in
            PersistentStorage sdPS = new PersistentStorage("SD");

            // Led stuff is in 
            OutputPort LED;
            LED = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, true);

            // Button stuff in
            InputPort Button;
            Button = new InputPort((Cpu.Pin)FEZ_Pin.Digital.LDR, false,
                                   Port.ResistorMode.PullUp);


            while (true)
            {
                //Led status at the beginning is off
                LED.Write(false);

                if (Button.Read())
                {

                    while (Button.Read()) ;   // wait while busy

                    //Led is on
                    LED.Write(true);

                    // Mount
                    sdPS.MountFileSystem();

                    // Start our new Thread
                    ExampleThread.Start();

                    while (Button.Read()) ;   // wait while busy

                    //Led is off
                    LED.Write(true);

                    // Abort our new Thread
                    ExampleThread.Abort();

                    // Unmount
                    sdPS.UnmountFileSystem();
                }

            }



        }
Ejemplo n.º 36
0
        public static void Test()
        {
            // Create new Thread that runs the ExampleThreadFunction
            Thread ExampleThread = new Thread(new ThreadStart(ExampleThreadFunction));

            // SD stuff is in
            PersistentStorage sdPS = new PersistentStorage("SD");

            // Led stuff is in
            OutputPort LED;

            LED = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, true);

            // Button stuff in
            InputPort Button;

            Button = new InputPort((Cpu.Pin)FEZ_Pin.Digital.LDR, false,
                                   Port.ResistorMode.PullUp);


            while (true)
            {
                //Led status at the beginning is off
                LED.Write(false);

                if (Button.Read())
                {
                    while (Button.Read())
                    {
                        ;                     // wait while busy
                    }
                    //Led is on
                    LED.Write(true);

                    // Mount
                    sdPS.MountFileSystem();

                    // Start our new Thread
                    ExampleThread.Start();

                    while (Button.Read())
                    {
                        ;                     // wait while busy
                    }
                    //Led is off
                    LED.Write(true);

                    // Abort our new Thread
                    ExampleThread.Abort();

                    // Unmount
                    sdPS.UnmountFileSystem();
                }
            }
        }
Ejemplo n.º 37
0
        public static void Main()
        {
            // Disable garbage collector messages
            Debug.EnableGCMessages(false);

            #region SD Card Init
            if (PersistentStorage.DetectSDCard())
            {
                // Assume SD card is connected
                try
                {
                    sdCardInterface = new PersistentStorage("SD");
                    sdCardInterface.MountFileSystem();
                }
                catch
                {
                    throw new Exception("SD card not detected");
                }

                if (File.Exists("\\SD\\Credentials.xml"))
                {
                    Debug.Print("Found Credentials.xml");
                    ParseCredentialsXML();
                }
            }
            #endregion

            //Setup_RLP();
            //Setup_WiFly_SPI1();
            Setup_CMUCam3_COM1();
            Setup_MotorController_COM2();

            //Test_MotorController();
            Test_Nunchuck();

            #region SD Card Cleanup
            if (PersistentStorage.DetectSDCard())
            {
                // Clean up SD card interface
                sdCardInterface.UnmountFileSystem();
                //ms.EnableLun(0);
                //ms.DisableLun(0);
            }
            #endregion

            // Sleep forever
            Debug.Print("Going to sleep...\n");
            Thread.Sleep(Timeout.Infinite);
        }
Ejemplo n.º 38
0
        public static void Main()
        {
            var addressSetting = new InputPort((Cpu.Pin) FEZ_Pin.Digital.Di52, false, Port.ResistorMode.Disabled);
            var address = addressSetting.Read() ? 2 : 1;

            var storage = new PersistentStorage("SD");
            storage.MountFileSystem();

            var receiver = new SerialReceiver("COM1", 115200, (byte)address);
            var handler = new CommandHandler(FEZ_Pin.Digital.Di8);

            receiver.CommandReceived += handler.HandleCommand;

            while(true)
                Thread.Sleep(1000);
        }
Ejemplo n.º 39
0
 static void Main(string[] args) {
   var ps=new PersistentStorage();
   ps.Open();
   //Topic.Process();
   Topic root=Topic.root;
   //root.value="LMNOPQRSTUVWXYZ";
   root.value="XYZ";
   Topic l1=root.Get("level1_a");
   //l1.value="123456789ABCDEFGIHKLMNOPQRSTUVWXYZ";
   //l1.value="123456789ABCDEFGH";
   l1.value="123456789AB";
   Topic l2=l1.Get("level2_a");
   l2.value=true;
   Topic.Process();
   Console.WriteLine("press Enter");
   Console.ReadLine();
   l2.Remove();
   Topic.Process();
   Console.WriteLine("press Enter");
   Console.ReadLine();
   ps.Close();
 }
Ejemplo n.º 40
0
        private ArrayList volumes = new ArrayList(); // Volumes

        #endregion Fields

        #region Constructors

        public FileBrowser(StorageType deviceType, Font font)
        {
            this.storageType = deviceType;
            this.font = font;

            if (deviceType == StorageType.SD)
            {
                //Font font = Resources.GetFont(Resources.FontResources.Small);

                // Check for an SD card
                //Bitmap LCD = new Bitmap(SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight);
                //LCD.Clear();
                //LCD.DrawText("Initializing SD card...", font, Color.White, 88, (SystemMetrics.ScreenHeight - font.Height) / 2);
                //LCD.Flush();

                try
                {
                    storage = new PersistentStorage("SD");
                    storage.MountFileSystem();
                }
                catch
                {
                    storage = null;

                    //LCD.Clear();
                    //LCD.DrawText("No SD card found.", font, Color.White, 88, (SystemMetrics.ScreenHeight - font.Height) / 2);
                    //LCD.Flush();

                    //Thread.Sleep(2000);
                    //Exit();
                }

                //LCD.Dispose();
                //LCD = null;
            }

            GetVolumes();
            PopulateVolumes();
        }
Ejemplo n.º 41
0
        /// <summary>
        /// Initialises the game.
        /// </summary>
        protected GameBase()
        {
            GameBase.singleton = this;

            this.uiElements = new UIElementCollection();
            this.fpsCounter = new FPSCounter();

            this.persistentStorage = new PersistentStorage();

            // :: Initialise Lua and register the Engine's functions.
            this.luaState = new Lua();
            this.RegisterClass(this);

            // :: Initialise the graphics device manager and register some events.
            this.graphics = new GraphicsDeviceManager(this);
            this.graphics.PreparingDeviceSettings +=
                new EventHandler<PreparingDeviceSettingsEventArgs>(PrepareGraphicsSettings);

            this.dialogueManager = new DialogueManager();

            this.Content.RootDirectory = "FSEGame";
        }
			IPersistentStorage GetStorage (Solution solution, string workingFolderPath)
			{
				lock (storageLock) {
					IPersistentStorage storage;
					if (storages.TryGetValue (solution.Id, out storage))
						return storage;
					if (!SolutionSizeAboveThreshold (solution)) {
						storage = NoOpPersistentStorageInstance;
					} else {
						storage = new PersistentStorage (workingFolderPath);
					}
					storages.Add (solution.Id, storage);
					return storage;
				}
			}
Ejemplo n.º 43
0
        private static void SDWatcher()
        {
            const int POLL_TIME = 500; // check every 500 millisecond
            bool exists;

            while (true)
            {
                try // If SD card was removed while mounting, it may throw exceptions
                {
                    exists = PersistentStorage.DetectSDCard();

                    // make sure it is fully inserted and stable
                    if (exists)
                    {
                        Thread.Sleep(50);
                        exists = PersistentStorage.DetectSDCard();
                    }

                    if (exists && sdCard == null)
                    {
                        sdCard = new PersistentStorage("SD");
                        sdCard.MountFileSystem();
                    }
                    else if (!exists && sdCard != null)
                    {
                        sdCard.UnmountFileSystem();
                        sdCard.Dispose();
                        sdCard = null;
                    }
                }
                catch
                {
                    if (sdCard != null)
                    {
                        sdCard.Dispose();
                        sdCard = null;
                    }
                }

                Thread.Sleep(POLL_TIME);
            }
        }
Ejemplo n.º 44
0
        public static void M ain()
        {   // nuovo device per storage
            PersistentStorage sdPS = new PersistentStorage("SD");
            // mount del filesystem
            sdPS.MountFileSystem();
            // nome del root directory del primo (e unico) volume montato (si assume che ci sia!) 
            if (VolumeInfo.GetVolumes()[0].IsFormatted)
            {
                string rootDirectory = VolumeInfo.GetVolumes()[0].RootDirectory;
                Debug.Print("Accesso ai file nella SD Card");
                string[] files = Directory.GetFiles(rootDirectory);
                string[] folders = Directory.GetDirectories(rootDirectory);
                Debug.Print("File contenuti nella cartella " + rootDirectory + " della SD card:");
                for (int i = 0; i < files.Length; i++)
                    Debug.Print(files[i]);
                Debug.Print("Cartelle contenute nella cartella " + rootDirectory + " della SD card:");
                for (int i = 0; i < folders.Length; i++)
                    Debug.Print(folders[i]);
                // lettura del contenuto del file
                //FileStream FileHandle = new FileStream(rootDirectory + @"hello.txt", FileMode.Open, FileAccess.Read);
                //byte[] data = new byte[100];

                //int read_count = FileHandle.Read(data, 0, data.Length);
                //FileHandle.Close();
                //Debug.Print("The size of data we read is: " + read_count.ToString());
                //Debug.Print("Data from file:");
                //Debug.Print(new string(Encoding.UTF8.GetChars(data), 0, read_count));


                FileStream FileHandleW = new FileStream(rootDirectory +
                                          @"\hello.txt", FileMode.Create);
                byte[] dataW =
                   Encoding.UTF8.GetBytes("This string will go in the file pla pla!");
                // write the data and close the file
                FileHandleW.Write(dataW, 0, dataW.Length);
                FileHandleW.Close();



                FileStream FileHandleR = new FileStream(rootDirectory +
                     @"\hello.txt", FileMode.Open, FileAccess.Read);
                byte[] dataR = new byte[100];
                // write the data and close the file
                int read_count = FileHandleR.Read(dataR, 0, dataR.Length);
                FileHandleR.Close();
                Debug.Print("The size of data we read is: " +
                            read_count.ToString());
                Debug.Print("Data from file:");
                Debug.Print(new string(Encoding.UTF8.GetChars(dataR), 0,
                      read_count));

        
            }
            else
            {
                Debug.Print("SD card non formattata. Formattare su un PC con FAT32/FAT16.");
            }
            sdPS.UnmountFileSystem();

            Thread.Sleep(Timeout.Infinite);
        }
Ejemplo n.º 45
0
Archivo: Habbo.cs Proyecto: habb0/IHI-1
        private void Init()
        {
            _loginId = new ResettableLazyDirty<int>(() => HabboActions.GetLoginIdFromHabboId(Id));
            _username = new ResettableLazyDirty<string>(() => HabboActions.GetHabboUsernameFromHabboId(Id));
            _dateCreated = new ResettableLazyDirty<DateTime>(() => HabboActions.GetCreationDateFromHabboId(Id));
            _lastAccess = new ResettableLazyDirty<DateTime>(() => HabboActions.GetLastAccessDateFromHabboId(Id));
            _credits = new ResettableLazyDirty<int>(() => HabboActions.GetCreditsFromHabboId(Id));

            _instanceStorage = new InstanceStorage();
            _persistentStorage = new PersistentStorage(this);

            _permissions = new ResettableLazyDirty<IDictionary<string, PermissionState>>(() => CoreManager.ServerCore.PermissionDistributor.GetHabboPermissions(this));

            _figure = new ResettableLazyDirty<HabboFigure>(() => LoadFigure());
            _motto = new ResettableLazyDirty<string>(() => HabboActions.GetMottoFromHabboId(Id));

            MessengerCategories = new HashSet<MessengerCategory>();
        }
Ejemplo n.º 46
0
 public SDCard()
 {
     IsMassStorageMounted = false;
     IsFileSystemMounted = false;
     _persistentStorage = new PersistentStorage("SD");
 }
 private void ReleaseCardStorage()
 {
     lock (this)
     {
         if (_cardStorage != null)
         {
             _cardStorage.UnmountFileSystem();
             _cardStorage.Dispose();
             _cardStorage = null;
         }
     }
 }
        private void TryDisposeSdStorageObject()
        {
            if (_sdStorage == null)
                return;

            _sdStorage.Dispose();
            _sdStorage = null;
        }
 private void InitializeSdStorage()
 {
     _sdStorage = new PersistentStorage("SD");
     _sdStorage.MountFileSystem();
 }
Ejemplo n.º 50
0
 public static void UnMountSD()
 {
     if (ps != null)
     {
         ps.UnmountFileSystem();
         isMounted = false;
         ps.Dispose();
         ps = null;
     }
 }
 private bool MountCardStorage()
 {
     if (PersistentStorage.DetectSDCard())
     {
         try
         {
             lock (this)
             {
                 _cardStorage = new PersistentStorage("SD");
                 _cardStorage.MountFileSystem();
             }
             return true;
         }
         catch (Exception)
         {
             ReleaseCardStorage();
             return false;
         }
     }
     return false;
 }
Ejemplo n.º 52
0
        public static bool MountSD()
        {
            lastErrorMsg = "";
            bool returnValue = false;

            if (PersistentStorage.DetectSDCard() == false)
            {
                lastErrorMsg = "SD Card not present.";
            }
            else
            {
                try
                {
                    ps = new PersistentStorage("SD");
                    ps.MountFileSystem();
                    isMounted = true;
                    returnValue = true;
                }
                catch (Exception e)
                {
                    if (ps != null)
                    {
                        ps.Dispose();
                        ps = null;
                    }
                    lastErrorMsg = e.Message;
                }
            }

            return returnValue;
        }
Ejemplo n.º 53
0
        public static void Main()
        {
            PageCollection finalPageCollection = null;
            var persistentStorage = new PersistentStorage("SD");
            persistentStorage.MountFileSystem();

            foreach (var volumeInfo in VolumeInfo.GetVolumes())
            {
                foreach (var filename in Directory.GetFiles(volumeInfo.RootDirectory))
                {
                    var extension = Path.GetExtension(filename);
                    var basename = Path.GetFileNameWithoutExtension(filename);
                    int address = Constants.UserStartAddress;

                    switch (basename.ToLower())
                    {
                        case "bootloader":
                            address = Constants.BootloaderStartAddress;
                            break;

                        case "bootlader":
                            address = Constants.BootloaderStartAddress;
                            break;

                        default:
                            address = Constants.UserStartAddress;
                            break;
                    }

                    switch (extension.ToLower())
                    {
                        case ".bit":
                            finalPageCollection = new BitFilePageCollection(
                                new FixedBufferReadStream(
                                    new FileStream(
                                        filename,
                                        FileMode.Open
                                        ),
                                    256
                                    ),
                                address
                                );
                            Debug.Print(((BitFilePageCollection)finalPageCollection).Header.FileName);
                            break;

                        case ".bin":
                            finalPageCollection = new BinFilePageCollection(
                                new FixedBufferReadStream(
                                    new FileStream(
                                        filename,
                                        FileMode.Open
                                        ),
                                    256
                                    ),
                                address
                                );
                            break;
                    }

                    if (finalPageCollection != null)
                    {
                        break;
                    }
                }
                if (finalPageCollection != null)
                {
                    break;
                }
            }

            Uploader.Upload(finalPageCollection);
        }
Ejemplo n.º 54
0
        public void Salva()
        {
            path = "\\SD";

            Completo = Count + "," + Temperatura + "," + UmiditaRelativa + "," + UmiditaTerreno + "," + CO2 + "," + Luminosita + "," + StatoUmidificatore.ToString() + "," + StatoAerazione.ToString() + "," + AperturaBotola + "\n";

            PersistentStorage sd = new PersistentStorage("SD");
            sd.MountFileSystem();
            //FileStream scrivi;

            path = VolumeInfo.GetVolumes()[0].RootDirectory;
            Debug.Print("accesso a sd");
            DirectoryInfo d = new DirectoryInfo(path);
            var files = d.GetFiles();
            bool flag = true;

            /*for (int i = 0; i < files.Length; i++)
            {
                if (files[i].Name == "GrowBoxLog.csv")
                {
                    flag = true;//il file di log esiste, quindi non lo crea
                    i = files.Length - 1;
                }
                else
                    flag = false;
            }
             */

            //if (flag == false)
                //scrivi = File.Create(path + @"\GB.csv");

                //scrivi = new FileStream(@"\GB.csv", FileMode.Create, FileAccess.Write, FileShare.None);
                StreamWriter write = new StreamWriter(path + @"\GB.csv");
            write.Write(Completo);
            write.Close();
            //scrivi.Close();
            Count++;
        }