Exemple #1
0
    /// <summary>
    /// Enumerates Unity output files and add necessary files into Xcode project file.
    /// It only add a reference entry into project.pbx file, without actually copy it.
    /// Xcode pre-build script will copy files into correct location.
    /// </summary>
    void UpdateUnityProjectFiles(string pathToBuiltProject)
    {
        var pbxPath = PathExt.Combine(
            XcodeProjectRoot,
            Path.ChangeExtension(XcodeProjectName, "xcodeproj"),
            "project.pbxproj");
        var pbx = new PBXProject();

        pbx.ReadFromFile(pbxPath);

        string classesPath = PathExt.Combine(XcodeProjectName, "Unity", "Classes");

        ProcessUnityDirectory(
            pbx,
            PathExt.Combine(pathToBuiltProject, "Classes"),
            PathExt.Combine(XcodeProjectRoot, classesPath),
            classesPath);

        string librariesPath = PathExt.Combine(XcodeProjectName, "Unity", "Libraries");

        ProcessUnityDirectory(
            pbx,
            PathExt.Combine(pathToBuiltProject, "Libraries"),
            PathExt.Combine(XcodeProjectRoot, librariesPath),
            librariesPath);

        pbx.WriteToFile(pbxPath);
    }
Exemple #2
0
        /// <summary>
        /// Executes the move operation
        /// </summary>
        protected override void Execute()
        {
            double progressMeter = 1.0 / Items.Length;

            Progress = 0;

            foreach (IDirectoryViewItem item in Items)
            {
                if (IsCanceled)
                {
                    break;
                }

                CurrentItem   = item;
                OperationName = "Przenoszenie " + CurrentItem.Name;

                //check if file exist in destination directory
                if (DestFileSystem.CheckIfObjectExist(PathExt.Combine(DestinationPath, item.Name, DestFileSystem.IsWindowsFileSystem)) && !overrideAll)
                {
                    var dialog = new FileExistDialog(item, DestinationPath);
                    dialog.ShowModalDialog();

                    if (dialog.Result == FileExistDalogResult.Override)
                    {
                        CommenceMove();
                        Progress += progressMeter;
                    }
                    else if (dialog.Result == FileExistDalogResult.OverrideAll)
                    {
                        overrideAll = true;
                        CommenceMove();
                        Progress += progressMeter;
                    }
                    else if (dialog.Result == FileExistDalogResult.CancelOperation)
                    {
                        IsCanceled = true;
                    }
                    //else if(result==FileExistDalogResult.DontOverride) - easy go to next item
                }
                else
                {
                    CommenceMove();
                    Progress += progressMeter;
                }
            }

            OperationName = Items.ContainsOneElement() ? "Przenoszenie " + Items.First().Name : string.Format("Przenoszenie {0} obiektów", Items.Length);
            if (!IsCanceled)
            {
                OnFinished();
            }
            else
            {
                Rollback();
            }
        }
Exemple #3
0
 public RenameOperation(IDirectoryViewItem objectToRename, string newName, FileSystemBase fileSystem)
     : base(fileSystem)
 {
     ObjectToRename = objectToRename;
     OldName        = ObjectToRename.Name;
     OldPath        = ObjectToRename.FullName;
     NewName        = newName;
     NewPath        = PathExt.Combine(PathExt.GetDirectoryName(ObjectToRename.FullName, ObjectToRename.IsWindowsFile), NewName, ObjectToRename.IsWindowsFile);
     OperationName  = "Zmiana nazwy z " + OldName + " na " + NewName;
 }
Exemple #4
0
        public override void Execute(object parameter)
        {
            var newDirectoryName = MessageService.ShowInput("Podaj nazwę katalogu:");

            if (newDirectoryName.IsNotNullAndNotEmpty())
            {
                var active    = MainViewModel.ActiveDirectoryContainer.ActiveView;
                var operation = new NewFolderOperation(PathExt.Combine(active.FullPath, newDirectoryName, active.FileSystem.IsWindowsFileSystem), active.FileSystem);
                OperationManager.ExecuteOperation(operation);
            }
        }
Exemple #5
0
        public static FTPFile CreateFromServerCall(edtFTPFile fileInfo, string baseDir, int accountId)
        {
            var file = new FTPFile(accountId);

            file.LastModifiedTime = fileInfo.LastModified;
            file.IsDirectory      = fileInfo.Dir;
            file.Size             = FileSize.CreateFromBytes(fileInfo.Size);
            file.name             = fileInfo.Name;
            file.fullName         = PathExt.Combine(baseDir, fileInfo.Name, false);

            return(file);
        }
Exemple #6
0
    /// <summary>
    /// Writes current Unity version and output path to 'Exports.xcconfig' file.
    /// </summary>
    void UpdateUnityIOSExports(string pathToBuiltProject)
    {
        var config = new StringBuilder();

        config.AppendFormat("UNITY_RUNTIME_VERSION = {0};{1}", Application.unityVersion, Environment.NewLine);
        config.AppendFormat("UNITY_IOS_EXPORT_PATH = {0};{1}", pathToBuiltProject, Environment.NewLine);

        var unityDir = PathExt.Combine(XcodeProjectRoot, XcodeProjectName, "Unity");

        Directory.CreateDirectory(unityDir);
        var ExportsConfigProjectPath = PathExt.Combine(unityDir, "Exports.xcconfig");

        File.WriteAllText(ExportsConfigProjectPath, config.ToString());
    }
Exemple #7
0
    private void ShowSettings()
    {
        GUILayout.Label("Settings", EditorStyles.boldLabel);

        // If we don't have a directory root for the xcode project, just make a wild
        // guess at one to give the user a starting point for navigating to the real one.
        if (!Directory.Exists(XcodeProjectPath))
        {
            XcodeProjectPath = null;
        }

        if (string.IsNullOrEmpty(XcodeProjectPath))
        {
            XcodeProjectPath = PathExt.Combine(
                Path.GetDirectoryName(Environment.CurrentDirectory),
                "Xcode-Project.xcodeproj");
        }

        // Instead of defining the xcode project root and name separately, have the user
        // select the .xcodeproj file and then figure them out from there.
        var xcodeProjectFile = PathExt.Abs2Rel(XcodeProjectPath);

        xcodeProjectFile = EditorGUILayout.TextField("Xcode Project File", xcodeProjectFile);

        if (GUILayout.Button("Browse..."))
        {
            string userSelection = null;
            if (Environment.OSVersion.Platform == PlatformID.MacOSX)
            {
                userSelection = EditorUtility.OpenFilePanelWithFilters(
                    "Select Xcode project file",
                    Path.GetDirectoryName(XcodeProjectPath),
                    XCODEPROJ_FILTER);
            }
            else
            {
                userSelection = EditorUtility.OpenFolderPanel(
                    "Select Xcode project file",
                    Path.GetDirectoryName(XcodeProjectPath),
                    "Xcode-Project.xcodeproj");
            }

            if (!string.IsNullOrEmpty(userSelection))
            {
                xcodeProjectFile = PathExt.Abs2Rel(userSelection);
            }
        }

        XcodeProjectPath = PathExt.Rel2Abs(xcodeProjectFile);
    }
 protected override void Rollback()
 {
     foreach (MultiRenameItem item in MRItems)
     {
         var oldPath = PathExt.Combine(PathExt.GetDirectoryName(item.Item.FullName, item.Item.IsWindowsFile), item.OldName, item.Item.IsWindowsFile);
         var newPath = PathExt.Combine(PathExt.GetDirectoryName(item.Item.FullName, item.Item.IsWindowsFile), item.NewName, item.Item.IsWindowsFile);
         if (FileSystem.CheckIfObjectExist(oldPath))
         {
             MessageBox.Show("Obiekt o nazwie " + item.OldName + " już isnieje. Nie mogę cofnąć operacji.");
         }
         else
         {
             FileSystem.Rename(newPath, oldPath, item.Item.IsDirectory);
         }
     }
 }
Exemple #9
0
    /// <summary>
    /// Make necessary changes to Unity build output that enables it to be embedded into existing Xcode project.
    /// </summary>
    private static void PatchUnityNativeCode(string pathToBuiltProject)
    {
        var unityVersion = ParseUnityVersionNumber(Application.unityVersion);

        EditMainMM(PathExt.Combine(pathToBuiltProject, "Classes/main.mm"));
        EditUnityAppControllerH(PathExt.Combine(pathToBuiltProject, "Classes/UnityAppController.h"));
        EditUnityAppControllerMM(PathExt.Combine(pathToBuiltProject, "Classes/UnityAppController.mm"));

        if (unityVersion == UNITY_VERSION_FOR_METAL_HELPER)
        {
            EditMetalHelperMM(PathExt.Combine(pathToBuiltProject, "Classes/Unity/MetalHelper.mm"));
        }

        if (unityVersion >= MIN_UNITY_VERSION_FOR_SPLASH_SCREEN)
        {
            EditSplashScreenMM(PathExt.Combine(pathToBuiltProject, "Classes/UI/SplashScreen.mm"));
        }
    }
        protected override void Execute()
        {
            foreach (MultiRenameItem item in MRItems)
            {
                var newPath = PathExt.Combine(PathExt.GetDirectoryName(item.Item.FullName, item.Item.IsWindowsFile), item.NewName, item.Item.IsWindowsFile);
                if (FileSystem.CheckIfObjectExist(newPath))
                {
                    MessageBox.Show("Obiekt o nazwie " + item.NewName + " już isnieje. Nie mogę przeprowadzić operacji.");
                    IsCanceled = true;
                }
                else
                {
                    FileSystem.Rename(item.Item.FullName, newPath, item.Item.IsDirectory);
                }
            }

            OnFinished();
        }
Exemple #11
0
    /// <summary>
    /// Update pbx project file by adding src files and removing extra files that
    /// exists in dest but not in src any more.
    ///
    /// This method only updates the pbx project file. It does not copy or delete
    /// files in Swift Xcode project. The Swift Xcode project will do copy and delete
    /// during build, and it should copy files if contents are different, regardless
    /// of the file time.
    /// </summary>
    /// <param name="pbx">The pbx project.</param>
    /// <param name="src">The directory where Unity project is built.</param>
    /// <param name="dest">The directory of the Swift Xcode project where the
    /// Unity project is embedded into.</param>
    /// <param name="projectPathPrefix">The prefix of project path in Swift Xcode
    /// project for Unity code files. E.g. "DempApp/Unity/Classes" for all files
    /// under Classes folder from Unity iOS build output.</param>
    void ProcessUnityDirectory(PBXProject pbx, string src, string dest, string projectPathPrefix)
    {
        var targetGuid = pbx.TargetGuidByName(XcodeProjectName);

        if (string.IsNullOrEmpty(targetGuid))
        {
            throw new Exception(string.Format("TargetGuid could not be found for '{0}'", XcodeProjectName));
        }

        // newFiles: array of file names in build output that do not exist in project.pbx manifest.
        // extraFiles: array of file names in project.pbx manifest that do not exist in build output.
        // Build output files that already exist in project.pbx manifest will be skipped to minimize
        // changes to project.pbx file.
        string[] newFiles, extraFiles;
        CompareDirectories(src, dest, out newFiles, out extraFiles);

        foreach (var projPath in
                 from f in newFiles
                 where !f.EndsWith(".bak", StringComparison.OrdinalIgnoreCase)
                 let projPath = Path.Combine(projectPathPrefix, f)
                                where !pbx.ContainsFileByProjectPath(projPath)
                                select projPath)
        {
            var guid = pbx.AddFile(projPath, projPath);
            pbx.AddFileToBuild(targetGuid, guid);

            Debug.LogFormat("Added file to pbx: '{0}'", projPath);
        }

        foreach (var projPath in
                 from f in extraFiles
                 let projPath = PathExt.Combine(projectPathPrefix, f)
                                where pbx.ContainsFileByProjectPath(projPath)
                                select projPath)
        {
            var guid = pbx.FindFileGuidByProjectPath(projPath);
            pbx.RemoveFile(guid);

            Debug.LogFormat("Removed file from pbx: '{0}'", projPath);
        }
    }
Exemple #12
0
        public static void OutputEmbededResource(String destinationDirectory, Assembly assembly, String filename, bool overwrite)
        {
            String outputFilePath = PathExt.Combine(destinationDirectory, filename);

            if (File.Exists(outputFilePath) && !overwrite)
            {
                return;
            }

            String[] names       = assembly.GetManifestResourceNames();
            String   theResource = String.Empty;

            foreach (String name in names)
            {
                if (name.EndsWith(filename))
                {
                    theResource = name;
                    break;
                }
            }
            if (theResource == String.Empty)
            {
                return;
            }
            System.IO.Stream manifestStream = assembly.GetManifestResourceStream(theResource);
            using (System.IO.FileStream fileStream = new System.IO.FileStream(outputFilePath, System.IO.FileMode.OpenOrCreate))
            {
                if (null != manifestStream)
                {
                    int    BUFFER_SIZE = (int)manifestStream.Length;
                    byte[] buffer      = new byte[BUFFER_SIZE];
                    manifestStream.Read(buffer, 0, BUFFER_SIZE);
                    fileStream.Write(buffer, 0, BUFFER_SIZE);
                    manifestStream.Close();
                }
            }
        }
Exemple #13
0
        public static string ToAbsolutePath(this string filename, string basePath)
        {
            var path = PathExt.Combine(PathExt.GetDirectoryPath(basePath), filename);

            return(path);
        }