unsafe static bool findFileInfo(string pattern, bool recursive, bool dirs, void *userData) { //!!!!!right? EngineThreading.CheckMainThread(); try { if (dirs) { //!!!!! string[] names = VirtualDirectory.GetDirectories("", pattern, recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly); foreach (string name in names) { findFileInfoAddItem(RenderingSystem.realRoot, name, Path.GetDirectoryName(name).Replace('\\', '/') + "/", Path.GetFileName(name), 0, 0, userData); } } else { string[] names = VirtualDirectory.GetFiles("", pattern, recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly); foreach (string name in names) { int length = (int)VirtualFile.GetLength(name); findFileInfoAddItem(RenderingSystem.realRoot, name, Path.GetDirectoryName(name).Replace('\\', '/') + "/", Path.GetFileName(name), length, length, userData); } } } catch { return(false); } return(true); }
static bool GetInfoFromSourceFile(string sourceFileName, out string hash, out int sourceFileSize) { try { var data = VirtualFile.ReadAllBytes(sourceFileName); //!!!!optimization: faster method maybe //!!!!optimization: может один раз создавать для всего? using (var sha = new SHA256Managed()) { byte[] checksum = sha.ComputeHash(data); hash = BitConverter.ToString(checksum).Replace("-", string.Empty); } sourceFileSize = (int)VirtualFile.GetLength(sourceFileName); return(true); } catch { hash = ""; sourceFileSize = 0; return(false); } }
void Play() { if (playCalling) { return; } playCalling = true; Stop(); if (EnabledInHierarchyAndIsNotResource && ParentScene != null) { var res = ParentRoot?.HierarchyController?.CreatedByResource; if (res != null && res.InstanceType == Resource.InstanceType.SeparateInstance) { var soundComponent = Sound.Value; if (soundComponent != null && soundComponent.Result != null) { bool streaming = false; switch (Streaming.Value) { case StreamingEnum.Auto: { string fileName = soundComponent.LoadFile.Value.ResourceName; if (!string.IsNullOrEmpty(fileName) && Path.GetExtension(fileName).ToLower() == ".ogg") { long length = 0; try { length = VirtualFile.GetLength(fileName); } catch { } if (length > 400000) { streaming = true; } } } break; case StreamingEnum.Enable: streaming = true; break; } SoundModes mode = SoundModes.Mode3D; if (ReplayDelay == 0 || streaming) //if( replayDelay == 0 ) { mode |= SoundModes.Loop; } if (streaming) { mode |= SoundModes.Stream; } sound = soundComponent.Result.LoadSoundByMode(mode); if (sound != null) { channel = SoundWorld.SoundPlay(ParentScene, sound, EngineApp.DefaultSoundChannelGroup, Priority, true); if (channel != null) { channel.Position = Transform.Value.Position; channel.Volume = Volume; UpdateChannelRolloffGraph(); channel.Pitch = Pitch; OnBeforePlay(); BeforePlayEvent?.Invoke(this); channel.Pause = false; lastUpdateEngineTime = EngineApp.EngineTime; } } } } } playCalling = false; }