Ejemplo n.º 1
0
        private bool applyFileChange(GhostFile file, String tmpPath)
        {
            Logger.log(Logger.TYPE.DEBUG, "Apply file change " + file.getName() + " path: " + tmpPath);
            bool   success = true;
            String tmpFile = Path.Combine(tmpPath, file.getName());
            String newPath = Path.Combine(getRootDir(), ((file is Archive) ?
                                                         ((Archive)file).getExtractTo() : file.getDestination()));

            if (verifyFile(tmpFile))
            {
                if (ensureDirectory(newPath))
                {
                    if (file is Archive)
                    {
                        try {
                            Archive archive = (Archive)file;
                            if (archive.getCleanDirs())
                            {
                                // TODO: Clean root directory
                            }

                            ArchiveHandler.extractZip(tmpFile, newPath, archive.getCleanDirs());

                            Logger.log(Logger.TYPE.DEBUG, "Extracted archive " + tmpFile + " to " + newPath);
                        }
                        catch (Exception ex) {
                            Logger.log(Logger.TYPE.ERROR, "Unable to patch new file to required"
                                       + " path. " + file.getName() + " " + ex.Message + ex.StackTrace);

                            success = false;
                        }
                    }
                    else
                    {
                        try {
                            File.Copy(tmpFile, Path.Combine(newPath, file.getName()), true);

                            Logger.log(Logger.TYPE.DEBUG, "Copied " + tmpFile + " to " + newPath);
                        }
                        catch (Exception ex) {
                            Logger.log(Logger.TYPE.ERROR, "Unable to patch new file to required"
                                       + " path. " + file.getName() + " " + ex.Message + ex.StackTrace);

                            success = false;
                        }
                    }
                }
            }
            return(success);
        }
Ejemplo n.º 2
0
 public void addFile(GhostFile file)
 {
     files.Add(file);
 }
Ejemplo n.º 3
0
 public void addFile(GhostFile file)
 {
     files.Add(file);
 }
Ejemplo n.º 4
0
        private bool applyFileChange(GhostFile file, String tmpPath)
        {
            Logger.log(Logger.TYPE.DEBUG, "Apply file change " + file.getName() + " path: " + tmpPath);
            bool success = true;
            String tmpFile = Path.Combine(tmpPath, file.getName());
            String newPath = Path.Combine(getRootDir(), ((file is Archive) ?
                ((Archive)file).getExtractTo() : file.getDestination()));

            if (verifyFile(tmpFile)) {
                if (ensureDirectory(newPath)) {
                    if (file is Archive) {
                        try {
                            Archive archive = (Archive)file;
                            if (archive.getCleanDirs()) {
                                // TODO: Clean root directory
                            }

                            ArchiveHandler.extractZip(tmpFile, newPath, archive.getCleanDirs());

                            Logger.log(Logger.TYPE.DEBUG, "Extracted archive " + tmpFile + " to " + newPath);
                        }
                        catch (Exception ex) {
                            Logger.log(Logger.TYPE.ERROR, "Unable to patch new file to required"
                                + " path. " + file.getName() + " " + ex.Message + ex.StackTrace);

                            success = false;
                        }
                    }
                    else {
                        try {
                            File.Copy(tmpFile, Path.Combine(newPath, file.getName()), true);

                            Logger.log(Logger.TYPE.DEBUG, "Copied " + tmpFile + " to " + newPath);
                        }
                        catch (Exception ex) {
                            Logger.log(Logger.TYPE.ERROR, "Unable to patch new file to required"
                                + " path. " + file.getName() + " " + ex.Message + ex.StackTrace);

                            success = false;
                        }
                    }
                }
            }
            return success;
        }