public Nfs3Procedure.Status RemoveFileOrDirectory(String parentDirectory, String name) { String localPathAndName = PlatformPath.LocalCombine(parentDirectory, name); ShareObject shareObject; if (shareObjectsByLocalPath.TryGetValue(localPathAndName, out shareObject)) { DisposeShareObject(shareObject); } if (File.Exists(localPathAndName)) { File.Delete(localPathAndName); return(Nfs3Procedure.Status.Ok); } if (Directory.Exists(localPathAndName)) { Directory.Delete(localPathAndName); return(Nfs3Procedure.Status.Ok); } return(Nfs3Procedure.Status.ErrorNoSuchFileOrDirectory); }
protected override async Task <CompareItemsResult> ExecuteAsync(CompareItemsMessage message) { return(await Task.Run(() => { var buildPath = Path.Combine(MessagingContext.GetBuildPath(), message.AppName, message.SessionId); var files = new List <string> (); using (var hashAlgorithm = Hash.GetAlgorithm()) { foreach (var file in message.Items) { var targetPath = Path.Combine(buildPath, PlatformPath.GetPathForCurrentPlatform(file.ItemSpec)); if (!File.Exists(targetPath)) { files.Add(file.ItemSpec); } else { using (var stream = File.OpenRead(targetPath)) { var localHash = hashAlgorithm.ComputeHashAsString(stream); if (file.Hash != localHash) { files.Add(file.ItemSpec); } } } } } return new CompareItemsResult { MissingFiles = files }; }).ConfigureAwait(continueOnCapturedContext: false)); }
protected override async Task <GetItemResult> ExecuteAsync(GetItemMessage message) { return(await Task.Run <GetItemResult> (() => { var targetPath = Path.GetFullPath(Path.Combine( MessagingContext.GetBuildPath(), message.AppName, message.SessionId, PlatformPath.GetPathForCurrentPlatform(message.ItemSpec))); var result = new GetItemResult(); if (File.Exists(targetPath)) { result.FileExists = true; // Avoiding sending the payload if the file is too large based on the defined limit by the the client if (new System.IO.FileInfo(targetPath).Length > message.LimitLength) { result.FileLengthExceedsLimit = true; } else { result.Content = File.ReadAllBytes(targetPath); } } return result; }).ConfigureAwait(continueOnCapturedContext: false)); }
/// <summary> /// 从 testBundle_path 目录装载指定名称的 asset bundle /// </summary> /// <param name="bundleName"> asset bundle 文件名 不需要指定目录 </param> /// <returns></returns> static public AssetBundle LoadBundle(string bundleName) { string testData_folder = testBundle_path + PlatformPath.GetPath(Application.platform); AssetBundle ab = AssetBundle.LoadFromFile(testData_folder + "/" + bundleName); return(ab); }
public override bool Execute() { if (!ShouldExecuteRemotely()) { return(base.Execute()); } try { BTouchToolPath = PlatformPath.GetPathForCurrentPlatform(BTouchToolPath); BaseLibDll = PlatformPath.GetPathForCurrentPlatform(BaseLibDll); TaskItemFixer.FixFrameworkItemSpecs(Log, item => OutputPath, TargetFramework.Identifier, References.Where(x => x.IsFrameworkItem()).ToArray()); TaskItemFixer.FixItemSpecs(Log, item => OutputPath, References.Where(x => !x.IsFrameworkItem()).ToArray()); var taskRunner = new TaskRunner(SessionId, BuildEngine4); var success = taskRunner.RunAsync(this).Result; if (success) { GetGeneratedSourcesAsync(taskRunner).Wait(); } return(success); } catch (Exception ex) { Log.LogErrorFromException(ex); return(false); } }
public static SpriteAtlas LoadSpriteAtlas(string tag) { var saab = AssetBundle.LoadFromFile(PlatformPath.StreamingPath(tag.ToLower())); var sa = saab.LoadAsset <SpriteAtlas>(tag); print("loaded " + tag + ":" + sa + " " + Time.frameCount); map.Add(tag, sa); return(sa); }
public string GetPath(PlatformPath path) { switch (path) { case PlatformPath.Ela: return GetElaPath(); case PlatformPath.Elide: return GetElidePath(); case PlatformPath.Root: return GetRootPath(); case PlatformPath.Docs: return GetDocsPath(); default: return null; } }
private IEnumerator DoLoadAsset(float delay) { yield return(new WaitForSeconds(delay)); var ab = AssetBundle.LoadFromFile(PlatformPath.StreamingPath("canvas")); var go = ab.LoadAsset <GameObject>("canvas"); print("loaded canvas " + Time.frameCount); GameObject.Instantiate <GameObject>(go); print("instance canvas " + Time.frameCount); }
public RootShareDirectory(String localShareDirectory, String shareName) { if (!PlatformPath.IsValidUnixFileName(shareName)) { throw new ArgumentException(String.Format("The share name you provided '{0}' is not valid (cannot have '/')", shareName)); } this.directoryInfo = new DirectoryInfo(localShareDirectory); this.driveInfo = new DriveInfo(directoryInfo.Root.FullName); this.localShareDirectory = localShareDirectory; this.shareName = shareName; }
async System.Threading.Tasks.Task CopyArchiveAsync(ISshCommands sshCommands) { var serverHomeDirectory = await sshCommands.GetHomeDirectoryAsync().ConfigureAwait(continueOnCapturedContext: false); var buildPath = PlatformPath.GetServerBuildPath(serverHomeDirectory, AppName, SessionId, TargetPath); if (!Directory.Exists(buildPath)) { await sshCommands.CreateDirectoryAsync(buildPath).ConfigureAwait(continueOnCapturedContext: false); } await sshCommands.CopyDirectoryAsync(ArchivePath, buildPath).ConfigureAwait(continueOnCapturedContext: false); }
public void Init() { Context context = Context.Unknown; ByteBuffer bb = TestData.LoadResource("suit_metal_dragon_male." + PlatformPath.GetPath(Application.platform).ToLower() + ".texture", out context); Assert.IsNotNull(bb); Assert.AreNotEqual(context, Context.Unknown); TextureUnserializer unserializer = UnserializerFactory.Instance.Create(context) as TextureUnserializer; result = unserializer.Parse(bb) as ResourceObjectSingle; Assert.IsNotNull(result); texture = Schema.Texture.GetRootAsTexture(bb); }
private IEnumerator DoLoadAsset(Action <SpriteAtlas> action, string tag) { yield return(new WaitForSeconds(3)); var ab = AssetBundle.LoadFromFileAsync(PlatformPath.StreamingPath(tag.ToLower())); yield return(ab); print("DoloadAsset frame:" + Time.frameCount); var sa = ab.assetBundle.LoadAsset <SpriteAtlas>(tag); print("sa: " + sa); action(sa); }
public string GetPath(PlatformPath path) { switch (path) { case PlatformPath.Ela: return(GetElaPath()); case PlatformPath.Elide: return(GetElidePath()); case PlatformPath.Root: return(GetRootPath()); case PlatformPath.Docs: return(GetDocsPath()); default: return(null); } }
private static void BuildAssetBundle(BuildTarget buildTarget) { var path = Application.streamingAssetsPath + "/" + PlatformPath.ToString(buildTarget); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } BuildPipeline.BuildAssetBundles(path, BuildAssetBundleOptions.None, //BuildAssetBundleOptions.ForceRebuildAssetBundle, //|BuildAssetBundleOptions.IgnoreTypeTreeChanges //|BuildAssetBundleOptions.DeterministicAssetBundle, buildTarget); AssetDatabase.Refresh(ImportAssetOptions.Default); }
void SetShareLeafName(String shareLeafName) { if (PlatformPath.IsValidUnixFileName(shareLeafName)) { this.shareLeafName = shareLeafName; } else { String newShareLeafName = NfsPath.LeafName(shareLeafName); if (!PlatformPath.IsValidUnixFileName(newShareLeafName)) { throw new InvalidOperationException(String.Format("The file you supplied '{0}' is not a valid unix file name", shareLeafName)); } this.shareLeafName = newShareLeafName; } }
public Nfs3Procedure.Status TryGetDirectory(String shareDirectoryName, out RootShareDirectory rootShareDirectory, out ShareObject shareDirectoryObject) { String subPath; String rootShareName = NfsPath.SplitShareNameAndSubPath(shareDirectoryName, out subPath); if (rootShareName == null) { rootShareDirectory = null; shareDirectoryObject = null; return(Nfs3Procedure.Status.ErrorInvalidArgument); } Nfs3Procedure.Status status = TryGetRootSharedDirectory(rootShareName, out rootShareDirectory); if (status != Nfs3Procedure.Status.Ok) { shareDirectoryObject = null; return(status); } if (rootShareDirectory == null) { shareDirectoryObject = null; return(Nfs3Procedure.Status.ErrorNoSuchFileOrDirectory); } if (subPath == null) { shareDirectoryObject = rootShareDirectory.shareObject; } else { String localPathAndName = PlatformPath.LocalCombine(rootShareDirectory.localShareDirectory, subPath); status = TryGetSharedObject(localPathAndName, subPath, out shareDirectoryObject); if (status != Nfs3Procedure.Status.Ok) { return(status); } if (shareDirectoryObject == null) { return(Nfs3Procedure.Status.ErrorNoSuchFileOrDirectory); } shareDirectoryObject.RefreshFileAttributes(permissions); } return(Nfs3Procedure.Status.Ok); }
public MkdirReply MKDIR(MkdirCall mkdirCall) { ShareObject parentDirectoryShareObject; Status status = sharedFileSystem.TryGetSharedObject(mkdirCall.directoryHandle, out parentDirectoryShareObject); if (status != Status.Ok) { return(new MkdirReply(status, BeforeAndAfterAttributes.None)); } String localPathAndName = PlatformPath.LocalCombine(parentDirectoryShareObject.localPathAndName, mkdirCall.newDirectoryName); ShareObject mkdirDirectoryShareObject; status = sharedFileSystem.TryGetSharedObject(localPathAndName, mkdirCall.newDirectoryName, out mkdirDirectoryShareObject); if (status == Nfs3Procedure.Status.Ok) { return(new MkdirReply(Status.ErrorAlreadyExists, BeforeAndAfterAttributes.None)); } if (status != Nfs3Procedure.Status.ErrorNoSuchFileOrDirectory) { return(new MkdirReply(status, BeforeAndAfterAttributes.None)); } parentDirectoryShareObject.RefreshFileAttributes(sharedFileSystem.permissions); SizeAndTimes directorySizeAndTimesBeforeCreate = AutoExtensions.CreateSizeAndTimes(parentDirectoryShareObject.fileAttributes); // Todo: handle exceptions Directory.CreateDirectory(localPathAndName); status = sharedFileSystem.TryGetSharedObject(localPathAndName, mkdirCall.newDirectoryName, out mkdirDirectoryShareObject); if (status != Nfs3Procedure.Status.Ok) { return(new MkdirReply(status, BeforeAndAfterAttributes.None)); } mkdirDirectoryShareObject.RefreshFileAttributes(sharedFileSystem.permissions); parentDirectoryShareObject.RefreshFileAttributes(sharedFileSystem.permissions); return(new MkdirReply(mkdirDirectoryShareObject.optionalFileHandleClass, parentDirectoryShareObject.optionalFileAttributes, new BeforeAndAfterAttributes(directorySizeAndTimesBeforeCreate, parentDirectoryShareObject.fileAttributes))); }
void Start() { if (upPath != null && !upPath.gameObject.activeInHierarchy) { upPath = null; } if (rightPath != null && !rightPath.gameObject.activeInHierarchy) { rightPath = null; } if (downPath != null && !downPath.gameObject.activeInHierarchy) { downPath = null; } if (leftPath != null && !leftPath.gameObject.activeInHierarchy) { leftPath = null; } }
public ShareObject TryGetSharedObject(FileType expectedFileType, String localParentDirectory, String localPathAndName) { switch (expectedFileType) { case FileType.Regular: if (!File.Exists(localPathAndName)) { return(null); } break; case FileType.Directory: if (!Directory.Exists(localPathAndName)) { return(null); } break; default: return(null); } ShareObject shareObject; if (shareObjectsByLocalPath.TryGetValue(localPathAndName, out shareObject)) { if (shareObject.fileType == expectedFileType) { return(shareObject); } DisposeShareObject(shareObject); } String shareName = PlatformPath.LocalPathDiff(localParentDirectory, localPathAndName); if (!PlatformPath.IsValidUnixFileName(shareName)) { throw new InvalidOperationException(String.Format("The file you supplied '{0}' is not a valid unix file name", shareName)); } return(CreateNewShareObject(expectedFileType, localPathAndName, shareName)); }
private float deathZone = -600f; //the y value to kill the gameobject at private void Start() { currentState = AiState.idle; canvas = Canvas.FindObjectOfType <Canvas>(); path = gameObject.AddComponent <PlatformPath>(); target = GameObject.FindGameObjectWithTag("Player"); pathList = new List <Node>(); start = false; done = false; StartCoroutine(findPath()); rb = gameObject.GetComponent <Rigidbody2D>(); anim = GetComponentInChildren <Animator>(); yDist = new Vector3(0, transform.position.y - path.nodePath[0].transform.position.y); health = maxHealth; thisHealthBar = Instantiate(healthbar); thisHealthBar.transform.SetParent(canvas.transform); thisHealthBar.transform.position = Camera.main.WorldToScreenPoint(gameObject.transform.position + new Vector3(0, 10, 0)); healthbar.SetActive(false); }
async System.Threading.Tasks.Task GetGeneratedSourcesAsync(TaskRunner taskRunner) { await taskRunner.GetFileAsync(GeneratedSourcesFileList).ConfigureAwait(continueOnCapturedContext: false); var localGeneratedSourcesFileNames = new List <string> (); var generatedSourcesFileNames = File.ReadAllLines(GeneratedSourcesFileList); foreach (var generatedSourcesFileName in generatedSourcesFileNames) { var localRelativePath = GetLocalRelativePath(generatedSourcesFileName); await taskRunner.GetFileAsync(localRelativePath).ConfigureAwait(continueOnCapturedContext: false); var localGeneratedSourcesFileName = PlatformPath.GetPathForCurrentPlatform(localRelativePath); localGeneratedSourcesFileNames.Add(localGeneratedSourcesFileName); } File.WriteAllLines(GeneratedSourcesFileList, localGeneratedSourcesFileNames); }
public LookupReply LOOKUP(LookupCall lookupCall) { // // Get Directory Object // ShareObject directoryShareObject; Status status = sharedFileSystem.TryGetSharedObject(lookupCall.directoryHandle, out directoryShareObject); if (status != Status.Ok) { return(new LookupReply(status, OptionalFileAttributes.None)); } if (directoryShareObject.fileType != FileType.Directory) { return(new LookupReply(Status.ErrorNotDirectory, OptionalFileAttributes.None)); } // // Get File // String localPathAndName = PlatformPath.LocalCombine(directoryShareObject.localPathAndName, lookupCall.fileName); ShareObject fileShareObject; sharedFileSystem.TryGetSharedObject(localPathAndName, lookupCall.fileName, out fileShareObject); if (status != Status.Ok) { return(new LookupReply(status, OptionalFileAttributes.None)); } if (fileShareObject == null) { return(new LookupReply(Status.ErrorNoSuchFileOrDirectory, OptionalFileAttributes.None)); } directoryShareObject.RefreshFileAttributes(sharedFileSystem.permissions); fileShareObject.RefreshFileAttributes(sharedFileSystem.permissions); return(new LookupReply(fileShareObject.fileHandleBytes, directoryShareObject.optionalFileAttributes, fileShareObject.optionalFileAttributes)); }
protected override async Task ExecuteAsync(CopyItemMessage message) { await Task.Run(async() => { var targetPath = Path.GetFullPath(Path.Combine( MessagingContext.GetBuildPath(), message.AppName, message.SessionId, PlatformPath.GetPathForCurrentPlatform(message.ItemSpec))); if (File.Exists(targetPath)) { File.Delete(targetPath); } else if (!Directory.Exists(Path.GetDirectoryName(targetPath))) { Directory.CreateDirectory(Path.GetDirectoryName(targetPath)); } using (var file = File.Create(targetPath)) using (var stream = new MemoryStream(message.Content)) await stream.CopyToAsync(file).ConfigureAwait(continueOnCapturedContext: false); }); }
// Update is called once per frame void Update() { // Move player to next level if (isMoving) { animator.SetFloat("Forward", 0.5f); transform.position = Vector3.MoveTowards(transform.position, _currentPoint.Current.position, Time.deltaTime * speed); var distanceSquared = (transform.position - _currentPoint.Current.position).sqrMagnitude; if (distanceSquared < maxDistanceToGoal * maxDistanceToGoal) { _currentPoint.MoveNext(); currentStop++; if (currentStop >= numStops) { isMoving = false; } else { mrBearMesh.transform.LookAt(_currentPoint.Current.position - new Vector3(0, levelHeightDif, 0f)); } } } // check for input when not moving else { animator.SetFloat("Forward", 0f); // enter level if on the level and you press jump if (Input.GetButton("Jump")) { PlayerPrefsManager.SetMapXPos(transform.position.x); PlayerPrefsManager.SetMapYPos(transform.position.y); PlayerPrefsManager.SetMapZPos(transform.position.z); levelManager.LoadLevel(currentLevel.name); } // determine direction to move to next level float x = Input.GetAxis("Horizontal"); float y = Input.GetAxis("Vertical"); if (y > 0 && currentLevel.upPath) { playerMovePath = currentLevel.upPath; MovePlayer(); } if (y < 0 && currentLevel.downPath) { playerMovePath = currentLevel.downPath; MovePlayer(); } if (x > 0 && currentLevel.rightPath) { playerMovePath = currentLevel.rightPath; MovePlayer(); } if (x < 0 && currentLevel.leftPath) { playerMovePath = currentLevel.leftPath; MovePlayer(); } } }
void OnTriggerEnter(Collider collider) { playerMovePath = null; currentLevel = collider.GetComponent <LevelSelect>(); }
public CreateReply CREATE(CreateCall createCall) { if (createCall.mode == CreateModeEnum.Exclusive) { return(new CreateReply(Status.ErrorNotSupported, BeforeAndAfterAttributes.None)); } ShareObject directoryShareObject; Status status = sharedFileSystem.TryGetSharedObject(createCall.directoryHandle, out directoryShareObject); if (status != Status.Ok) { return(new CreateReply(status, BeforeAndAfterAttributes.None)); } FileStream fileStream = null; try { String localPathAndName = PlatformPath.LocalCombine(directoryShareObject.localPathAndName, createCall.newFileName); ShareObject fileShareObject; status = sharedFileSystem.TryGetSharedObject(localPathAndName, createCall.newFileName, out fileShareObject); if (status == Nfs3Procedure.Status.Ok) { fileShareObject.RefreshFileAttributes(sharedFileSystem.permissions); // The file already exists if (createCall.mode == CreateModeEnum.Guarded) { return(new CreateReply(Status.ErrorAlreadyExists, BeforeAndAfterAttributes.None)); } } else { if (status != Nfs3Procedure.Status.ErrorNoSuchFileOrDirectory) { return(new CreateReply(status, BeforeAndAfterAttributes.None)); } } directoryShareObject.RefreshFileAttributes(sharedFileSystem.permissions); SizeAndTimes directorySizeAndTimesBeforeCreate = AutoExtensions.CreateSizeAndTimes(directoryShareObject.fileAttributes); // Todo: handle exceptions fileStream = new FileStream(localPathAndName, FileMode.Create); fileStream.Dispose(); status = sharedFileSystem.TryGetSharedObject(localPathAndName, createCall.newFileName, out fileShareObject); if (status != Nfs3Procedure.Status.Ok) { return(new CreateReply(status, BeforeAndAfterAttributes.None)); } fileShareObject.RefreshFileAttributes(sharedFileSystem.permissions); directoryShareObject.RefreshFileAttributes(sharedFileSystem.permissions); return(new CreateReply(fileShareObject.optionalFileHandleClass, fileShareObject.optionalFileAttributes, new BeforeAndAfterAttributes(directorySizeAndTimesBeforeCreate, directoryShareObject.fileAttributes))); } finally { if (fileStream != null) { fileStream.Dispose(); } } }
private ShaderManager() { coreDataBundle = ".coreData/" + PlatformPath.GetPath(Application.platform) + "/coredata.bundle"; }
public Nfs3Procedure.Status Move(ShareObject oldParentShareObject, String oldName, ShareObject newParentShareObject, String newName) { Nfs3Procedure.Status status; status = newParentShareObject.CheckStatus(); if (status != Nfs3Procedure.Status.Ok) { DisposeShareObject(newParentShareObject); return(status); } status = oldParentShareObject.CheckStatus(); if (status != Nfs3Procedure.Status.Ok) { DisposeShareObject(oldParentShareObject); return(status); } // // Get Old Share Object // String oldLocalPathAndName = PlatformPath.LocalCombine(oldParentShareObject.localPathAndName, oldName); ShareObject oldShareObject; if (!shareObjectsByLocalPath.TryGetValue(oldLocalPathAndName, out oldShareObject)) { return(Nfs3Procedure.Status.ErrorNoSuchFileOrDirectory); } status = oldShareObject.CheckStatus(); if (status != Nfs3Procedure.Status.Ok) { DisposeShareObject(oldShareObject); return(status); } // // Move // String newLocalPathAndName = PlatformPath.LocalCombine(newParentShareObject.localPathAndName, newName); FileType fileType = oldShareObject.fileType; if (Directory.Exists(newLocalPathAndName)) { if (oldShareObject.fileType != FileType.Directory) { return(Nfs3Procedure.Status.ErrorAlreadyExists); } try { Directory.Delete(newLocalPathAndName); } catch (IOException) { return(Nfs3Procedure.Status.ErrorDirectoryNotEmpty); // The directory is not empty } Directory.Move(oldLocalPathAndName, newLocalPathAndName); } else if (File.Exists(newLocalPathAndName)) { if (oldShareObject.fileType != FileType.Regular) { return(Nfs3Procedure.Status.ErrorAlreadyExists); } File.Delete(newLocalPathAndName); File.Move(oldLocalPathAndName, newLocalPathAndName); } else { if (oldShareObject.fileType == FileType.Regular) { File.Move(oldLocalPathAndName, newLocalPathAndName); } else if (oldShareObject.fileType == FileType.Directory) { Directory.Move(oldLocalPathAndName, newLocalPathAndName); } else { return(Nfs3Procedure.Status.ErrorInvalidArgument); } } // // Update the share object and return // UpdateShareObjectPathAndName(oldShareObject, newLocalPathAndName, newName); oldShareObject.RefreshFileAttributes(permissions); status = oldShareObject.CheckStatus(); if (status != Nfs3Procedure.Status.Ok) { DisposeShareObject(oldShareObject); } return(status); }
static ResourceObjectMaterial() { platform = PlatformPath.GetPath(Application.platform).ToLower(); }
private static AssetBundle LoadAB(string abpath) { string path = PlatformPath.StreamingPath(abpath); return(AssetBundle.LoadFromFile(path)); }