From 72145be8a38417145abdc87657d6ebebfbae3057 Mon Sep 17 00:00:00 2001 From: weizhou Date: Wed, 14 Jan 2015 17:40:28 +0800 Subject: [PATCH 1/5] add ppath command Print application's 'Documents' directory path. --- commands/FBPrintCommands.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/commands/FBPrintCommands.py b/commands/FBPrintCommands.py index b9907c9..e483d14 100644 --- a/commands/FBPrintCommands.py +++ b/commands/FBPrintCommands.py @@ -29,6 +29,7 @@ def lldbcommands(): FBPrintInternals(), FBPrintInstanceVariable(), FBPrintKeyPath(), + FBPrintApplicationDocumentsPath(), ] class FBPrintViewHierarchyCommand(fb.FBCommand): @@ -299,3 +300,15 @@ def run(self, arguments, options): object = fb.evaluateObjectExpression(objectToMessage) printCommand = 'po [{} valueForKeyPath:@"{}"]'.format(object, keypath) lldb.debugger.HandleCommand(printCommand) + + +class FBPrintApplicationDocumentsPath(fb.FBCommand): + def name(self): + return 'ppath' + + def description(self): + return "Print application's 'Documents' directory path." + + def run(self, arguments, options): + lldb.debugger.HandleCommand('po [NSSearchPathForDirectoriesInDomains(9, 1, YES) lastObject]') # NSDocumentDirectory == 9 NSUserDomainMask == 1 + From ff0d7631def44d0d7a87d225261242cec0741759 Mon Sep 17 00:00:00 2001 From: weizhou Date: Thu, 15 Jan 2015 10:17:12 +0800 Subject: [PATCH 2/5] change command name --- commands/FBPrintCommands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/FBPrintCommands.py b/commands/FBPrintCommands.py index e483d14..28fc682 100644 --- a/commands/FBPrintCommands.py +++ b/commands/FBPrintCommands.py @@ -304,7 +304,7 @@ def run(self, arguments, options): class FBPrintApplicationDocumentsPath(fb.FBCommand): def name(self): - return 'ppath' + return 'pdocspath' def description(self): return "Print application's 'Documents' directory path." From e6e9f5198274f816b83ecfa4b12bc4e425d1f052 Mon Sep 17 00:00:00 2001 From: weizhou Date: Thu, 29 Jan 2015 01:18:07 +0800 Subject: [PATCH 3/5] option -o "open in finder" not fully tested yet --- commands/FBPrintCommands.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/commands/FBPrintCommands.py b/commands/FBPrintCommands.py index 28fc682..257bb1c 100644 --- a/commands/FBPrintCommands.py +++ b/commands/FBPrintCommands.py @@ -308,7 +308,19 @@ def name(self): def description(self): return "Print application's 'Documents' directory path." + + def options(self): + return [ + fb.FBCommandArgument(short='-o', long='--open', arg='open', boolean=True, default=False, help='open in Finder'), + ] def run(self, arguments, options): - lldb.debugger.HandleCommand('po [NSSearchPathForDirectoriesInDomains(9, 1, YES) lastObject]') # NSDocumentDirectory == 9 NSUserDomainMask == 1 + if options.open: + path = fb.evaluateExpressionValue('(NSString *)[NSSearchPathForDirectoriesInDomains(9, 1, YES) lastObject]') + pathString = '{}'.format(path).split('"')[1] + print pathString + lldb.debugger.HandleCommand('script os.system("open {}")'.format(pathString)) + else: + lldb.debugger.HandleCommand('po [NSSearchPathForDirectoriesInDomains(9, 1, YES) lastObject]') # NSDocumentDirectory == 9 NSUserDomainMask == 1 + From f3119a6167e12dfb4612015b26030673c05236bc Mon Sep 17 00:00:00 2001 From: weizhou Date: Wed, 18 Mar 2015 00:06:07 +0800 Subject: [PATCH 4/5] refactor pdocspath --- commands/FBPrintCommands.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/commands/FBPrintCommands.py b/commands/FBPrintCommands.py index 257bb1c..c3e19de 100644 --- a/commands/FBPrintCommands.py +++ b/commands/FBPrintCommands.py @@ -315,12 +315,13 @@ def options(self): ] def run(self, arguments, options): + # in iOS SDK NSDocumentDirectory == 9 NSUserDomainMask == 1 + NSDocumentDirectory = '9' + NSUserDomainMask = '1' + path = fb.evaluateExpressionValue('(NSString*)[NSSearchPathForDirectoriesInDomains(' + NSDocumentDirectory + ', ' + NSUserDomainMask + ', YES) lastObject]') + pathString = '{}'.format(path).split('"')[1] + print pathString if options.open: - path = fb.evaluateExpressionValue('(NSString *)[NSSearchPathForDirectoriesInDomains(9, 1, YES) lastObject]') - pathString = '{}'.format(path).split('"')[1] - print pathString - lldb.debugger.HandleCommand('script os.system("open {}")'.format(pathString)) - else: - lldb.debugger.HandleCommand('po [NSSearchPathForDirectoriesInDomains(9, 1, YES) lastObject]') # NSDocumentDirectory == 9 NSUserDomainMask == 1 + os.system('open '+ pathString) From 84d60b8726d78cd00923c1f2c2525144b0b94821 Mon Sep 17 00:00:00 2001 From: weizhou Date: Fri, 27 Mar 2015 13:58:57 +0800 Subject: [PATCH 5/5] copy to the pasteboard before print --- commands/FBPrintCommands.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/commands/FBPrintCommands.py b/commands/FBPrintCommands.py index c3e19de..7220c99 100644 --- a/commands/FBPrintCommands.py +++ b/commands/FBPrintCommands.py @@ -320,6 +320,8 @@ def run(self, arguments, options): NSUserDomainMask = '1' path = fb.evaluateExpressionValue('(NSString*)[NSSearchPathForDirectoriesInDomains(' + NSDocumentDirectory + ', ' + NSUserDomainMask + ', YES) lastObject]') pathString = '{}'.format(path).split('"')[1] + cmd = 'echo {} | tr -d "\n" | pbcopy'.format(pathString) + os.system(cmd) print pathString if options.open: os.system('open '+ pathString)