Esempio n. 1
0
        public bool Load(string path, bool minimalCache)
        {
            _hostPath = path;

            DirectoryInfo info = new DirectoryInfo(path);

            _root = new MediaFolder(this, null, info);

            long used = _root.Cache();

            _available = _capacity - used;
            if (_available < 0)
            {
                // User gave a capacity that is too small for the size, fix it up
                while (_capacity < used)
                {
                    _capacity *= 2;
                }
                Log.WriteLine(Verbosity.Critical, Feature.Media, "UmdDevice: user gave capacity {0} but {1} is used; changing capacity to {2}",
                              _capacity, used, _capacity);
            }

            // Would be nice to do something with this that was official-like (serial number?)
            _description = string.Format("UMD ({0}MB)",
                                         _capacity / 1024 / 1024);

            return(true);
        }
Esempio n. 2
0
        public MemoryStickDevice( IEmulationInstance emulator, ComponentParameters parameters, string hostPath, bool writeProtected, long capacity )
        {
            Debug.Assert( emulator != null );
            Debug.Assert( parameters != null );
            Debug.Assert( hostPath != null );
            Debug.Assert( Directory.Exists( hostPath ) == true );
            Debug.Assert( capacity > 0 );

            _emulator = emulator;
            _parameters = parameters;
            _hostPath = hostPath;
            _writeProtected = writeProtected;

            DirectoryInfo info = new DirectoryInfo( hostPath );
            _root = new MediaFolder( this, null, info );

            _capacity = capacity;
            long used = _root.Cache();
            _available = _capacity - used;
            if( _available < 0 )
            {
                // User gave a capacity that is too small for the size, fix it up
                while( _capacity < used )
                    _capacity *= 2;
                Log.WriteLine( Verbosity.Critical, Feature.Media, "MemoryStickDevice: user gave capacity {0} but {1} is used; changing capacity to {2}",
                    capacity, used, _capacity );
            }

            // Would be nice to do something with this that was official-like (serial number?)
            _description = string.Format( "Memory Stick ({0}MB){1}",
                _capacity / 1024 / 1024,
                ( _writeProtected == true ? " read-only" : "" ) );
        }
Esempio n. 3
0
        internal long Cache()
        {
            long sum = 0;

            foreach (DirectoryInfo info in _info.GetDirectories())
            {
                MediaFolder folder = new MediaFolder(_device, this, info);
                sum += folder.Cache();
            }

            foreach (FileInfo info in _info.GetFiles())
            {
                MediaFile file = new MediaFile(_device, this, info);
                sum += file.Length;
            }

            return(sum);
        }
Esempio n. 4
0
        public MemoryStickDevice(IEmulationInstance emulator, ComponentParameters parameters, string hostPath, bool writeProtected, long capacity)
        {
            Debug.Assert(emulator != null);
            Debug.Assert(parameters != null);
            Debug.Assert(hostPath != null);
            Debug.Assert(Directory.Exists(hostPath) == true);
            Debug.Assert(capacity > 0);

            _emulator       = emulator;
            _parameters     = parameters;
            _hostPath       = hostPath;
            _writeProtected = writeProtected;

            DirectoryInfo info = new DirectoryInfo(hostPath);

            _root = new MediaFolder(this, null, info);

            _capacity = capacity;
            long used = _root.Cache();

            _available = _capacity - used;
            if (_available < 0)
            {
                // User gave a capacity that is too small for the size, fix it up
                while (_capacity < used)
                {
                    _capacity *= 2;
                }
                Log.WriteLine(Verbosity.Critical, Feature.Media, "MemoryStickDevice: user gave capacity {0} but {1} is used; changing capacity to {2}",
                              capacity, used, _capacity);
            }

            // Would be nice to do something with this that was official-like (serial number?)
            _description = string.Format("Memory Stick ({0}MB){1}",
                                         _capacity / 1024 / 1024,
                                         (_writeProtected == true ? " read-only" : ""));
        }
Esempio n. 5
0
 public void Refresh()
 {
     // TODO: Figure out a way to update space nicely WITHOUT rewalking everything
     _root.Drop();
     _root.Cache();
 }
Esempio n. 6
0
        public bool Load( string path, bool minimalCache )
        {
            _hostPath = path;

            DirectoryInfo info = new DirectoryInfo( path );
            _root = new MediaFolder( this, null, info );

            long used = _root.Cache();
            _available = _capacity - used;
            if( _available < 0 )
            {
                // User gave a capacity that is too small for the size, fix it up
                while( _capacity < used )
                    _capacity *= 2;
                Log.WriteLine( Verbosity.Critical, Feature.Media, "UmdDevice: user gave capacity {0} but {1} is used; changing capacity to {2}",
                    _capacity, used, _capacity );
            }

            // Would be nice to do something with this that was official-like (serial number?)
            _description = string.Format( "UMD ({0}MB)",
                _capacity / 1024 / 1024 );

            return true;
        }
Esempio n. 7
0
        internal long Cache()
        {
            long sum = 0;

            foreach( DirectoryInfo info in _info.GetDirectories() )
            {
                MediaFolder folder = new MediaFolder( _device, this, info );
                sum += folder.Cache();
            }

            foreach( FileInfo info in _info.GetFiles() )
            {
                MediaFile file = new MediaFile( _device, this, info );
                sum += file.Length;
            }

            return sum;
        }