This is a static copy of a profile reportHome
graphics/private/name (40 calls, 0.077 sec)
Generated 05-Aug-2011 13:00:29 using cpu time.
function in file /usr/local/MATLAB/R2011a/toolbox/matlab/graphics/private/name.m
Copy to new window for comparing multiple runs
Parents (calling functions)
| Function Name | Function Type | Calls |
| print | function | 40 |
Lines where the most time was spent
| Line Number | Code | Calls | Total Time | % Time | Time Plot |
| 55 | [p,n,e] = fileparts( pj.FileNa... | 40 | 0.033 s | 42.9% |  |
| 94 | fclose(fidappend); | 40 | 0.011 s | 14.3% |  |
| 84 | pj.FileName = fullfile(fpath,[... | 40 | 0.011 s | 14.3% |  |
| 56 | if isempty( e ) | 40 | 0.011 s | 14.3% |  |
| 14 | objName = ['figure' int2str( d... | 40 | 0.011 s | 14.3% |  |
| All other lines | | | 0 s | 0% |  |
| Totals | | | 0.077 s | 100% | |
Children (called functions)
Code Analyzer results
No Code Analyzer messages.Coverage results
[ Show coverage for parent directory ]
| Total lines in function | 124 |
| Non-code lines (comments, blank lines) | 48 |
| Code lines (lines that can run) | 76 |
| Code lines that did run | 33 |
| Code lines that did not run | 43 |
| Coverage (did run/can run) | 43.42 % |
Function listing
time calls line
1 function pj = name( pj )
2 %NAME Method to check or create valid filename.
3 % Validate FileName in PrintJob object. If empty, no name passed to PRINT
4 % command, but one is required by the driver, image file formats, we invent
5 % a name and tell the user what it is. Also invent name, but do not tell
6 % user, for temporary PS file created on disk when printing directly
7 % to output device or for GhostScript conversion.
8
9 % Copyright 1984-2010 The MathWorks, Inc.
10 % $Revision: 1.8.4.12 $
11
12 %Generate a name we would use if had to in various circumstances.
40 13 if isfigure( pj.Handles{1}(1) )
0.01 40 14 objName = ['figure' int2str( double(pj.Handles{1}(1) ))];
15 else
16 objName = get_param(pj.Handles{1}(1),'name');
17 end
18
40 19 tellUserFilename = 0;
40 20 if isempty(pj.FileName)
21 if pj.DriverExport && ...
22 ~strcmp(pj.DriverClass,'MW') && ~pj.DriverClipboard && ~pj.RGBImage
23 %These kinds of files shouldn't go to printer, generate file on disk
24 pj.FileName = objName;
25 tellUserFilename = 1;
26
27 else
28 %File is going to be sent to an output device by OS or us.
29 if ~strcmp(pj.DriverClass,'MW') && ~pj.DriverClipboard && ~pj.RGBImage
30 %Going to a file, invent a name
31 pj.FileName = tempname;
32 pj.PrintOutput = 1;
33 end
34 end
35
36 % only support going to clipboard w/o specifying -clipboard option
37 % for the grandfathered cases on Windows
38 if ~pj.ClipboardOption && pj.DriverClipboard
39 if ~ispc || (ispc && ~any(strcmp(pj.Driver, {'meta', 'bitmap'})))
40 pj.FileName = objName;
41 tellUserFilename = 1;
42 end
43 end
40 44 else
45 %Both / and \ are commonly used, but in MATLAB we recognize only filesep
40 46 pj.FileName = strrep( pj.FileName, '/', filesep );
40 47 pj.FileName = strrep( pj.FileName, '\', filesep );
40 48 end
49
50 %Append appropriate extension to filename if
51 % 1) it doesn't have one, and
52 % 2) we've determined a good one
40 53 if ~isempty( pj.DriverExt ) && ~isempty( pj.FileName )
54 %Could assert that ~isempty( pj.FileName )
0.03 40 55 [p,n,e] = fileparts( pj.FileName );
0.01 40 56 if isempty( e )
57 pj.FileName = fullfile( p, [n '.' pj.DriverExt] );
58 end
40 59 end
60
61 % on unix fix the file spec if it starts with '~/' so we look at the user's home dir
40 62 if (isunix)
40 63 pj.FileName = fixTilde(pj.FileName);
40 64 end
65
40 66 if tellUserFilename
67 %Invented name above because of device or bad filename
68 if tellUserFilename == 1
69 errStr1 = sprintf( 'Files produced by the ''%s'' driver cannot be sent to printer.\n', pj.Driver);
70 else
71 errStr1 = '';
72 end
73
74 warning('MATLAB:Print:SavingToDifferentName',...
75 '%sFile saved to disk under name ''%s''.', errStr1, pj.FileName )
76 end
77
78 % Check that we can write to the output file
40 79 if ~isempty(pj.FileName)
40 80 [fpath,fname,ext] = fileparts(pj.FileName);
40 81 if isempty(fpath)
82 fpath = '.';
83 end
0.01 40 84 pj.FileName = fullfile(fpath,[fname ext]);
85 % first check if readable file already exists there
40 86 fidread = fopen(pj.FileName,'r');
40 87 didnotexist = (fidread == -1);
40 88 if ~didnotexist
89 fclose(fidread);
90 end
91 % now check if file is appendable (will create file if not there)
40 92 fidappend = fopen(pj.FileName,'a');
40 93 if fidappend ~= -1
0.01 40 94 fclose(fidappend);
95 % check if we have to delete the created file
40 96 if didnotexist
97 % @todo Replace This once we have a flag on delete
98 % for disabling the recycle.
40 99 ov=recycle('off');
40 100 delete(pj.FileName);
40 101 recycle(ov);
40 102 end
103 else
104 error('MATLAB:Print:CannotCreateOutputFile',...
105 'Cannot create output file ''%s''', pj.FileName);
106 end
40 107 end
108
109 %A little business to clear up.
110 %Now that we found good extension and all that for GS driver,
111 %we swap in a PS driver and temporary name for later conversion
112 %to a file whose name we just prettied up.
40 113 if strcmp( pj.DriverClass, 'GS' )
114 %Remember actual device, get MATLAB to produce PostScript
115 %for later conversion by GhostScript
116 pj.GhostDriver = pj.Driver;
117 if pj.DriverColor
118 pj.Driver = 'psc';
119 else
120 pj.Driver = 'ps';
121 end
122 pj.GhostName = pj.FileName;
123 pj.FileName = [tempname '.ps'];
124 end
Other subfunctions in this file are not included in this listing.