Ho do the following lines to change the security class of a file translate into MT?
Change the class of a file: -[NSFileManager setAttributes:ofItemAtPath:error:]
Attribute: NSFileProtectionKey (NSFileProtectionComplete, NSFileProtectionNone)
How do I change the class of a file in MT?
And even more: If I manage to change the class, how can I verify that it worked?
Something like this:
NSError error;
var dict = new NSMutableDictionary ();
dict.SetObject ("NSFileProtectionComplete", "NSFileProtectionKey");
mgr.SetAttributes (path, dict, out error);
Related
I was working on COM/ATL. I need to use a class object as return value so that it can be used in managed code. I am able to define structure in idl file and also able to use it as return parameter when creating methods.
Below is the partial idl file implementation:
import "oaidl.idl";
import "ocidl.idl";
//Structure for message mapping of activation and deactivation
//Structures are working properly
[uuid(E2240D8B-EB97-4ACD-AC96-21F2EAFFE100)]
struct tagActivationManaged
{
WORD wMsgId;
WORD wStatus;
WORD wClient;
WORD wClientId;
};
//same manner if creating class it throws error.
[uuid(2ED2E59C-9362-46b2-80D8-471AD69BA5D5)]
class AuthenticationMessage
{
public:
Word message;
}
do I need to change any settings in MIDL.
NB: I am new to COM programming.
You just can't do that - there're no C++ flavor classes in IDL. If you want to return an object of some class from a function you have to declare an interface and possibly a coclass (the latter may not be required depending on your sitiation) and make the function return that interface.
What I've Done
I am using soapUI (3.6.1 Free version) mock services to serve up specific data to 2 client applications I am testing. With some simple Groovy script I've set up some mock operations to fetch responses from specific files based on the requests made by the client applications.
The static contents of the mock response is:
${responsefile}
The groovy in the operation dispatch scripting pane is:
def req = new XmlSlurper().parseText(mockRequest.requestContent)
if (req =~ "CategoryA")
{
context.responsefile = new File("C:/soapProject/Test_Files/ID_List_CategoryA.xml").text
}
else
{
context.responsefile = new File("C:/soapProject/Test_Files/ID_List_CategoryB.xml").text
}
In this example, when the client application issues a request to the mock service that contains the string CategoryA, the response returned by soapUI is the contents of file ID_List_CategoryA.xml
What I'm Trying To Achieve
This all works fine with the absolute paths in the groovy. Now I want to pull the whole collection of soapUI project file and external files into a package for easy re-deployment. From my reading about soapUI I hoped this would be as easy as setting the project Resource Root value to ${projectDir} and changing my paths to:
def req = new XmlSlurper().parseText(mockRequest.requestContent)
if (req =~ "CategoryA")
{
context.responsefile = new File("Test_Files/ID_List_CategoryA.xml").text
}
else
{
context.responsefile = new File("Test_Files/ID_List_CategoryB.xml").text
}
... keeping in mind that the soapUI project xml file resides in C:/soapProject/
What I've Tried So Far
So, that doesn't work. I've tried variations of relative paths:
./Test_Files/ID_List_CategoryA.xml
/Test_Files/ID_List_CategoryA.xml
Test_Files/ID_List_CategoryA.xml
One post indicated that soapUI might consider the project files parent directory as the root for the purposes of the relative path, so tried the following variations too:
./soapProject/Test_Files/ID_List_CategoryA.xml
/soapProject/Test_Files/ID_List_CategoryA.xml
soapProject/Test_Files/ID_List_CategoryA.xml
When none of that worked I tried making use of the ${projectDir} property in the groovy script, but all such attempts failed with a "No such property: mockService for class: Script[n]" error. Admittefly, I was really fumbling around when trying to do that.
I tried using information from this post and others: How do I make soapUI attachment paths relative?
... without any luck. Replacing "test" with "mock," (among other changes), in the solution code from that post resulted in more property errors, e.g.
testFile = new File(mockRunner.project.getPath())
.. led to...
No such property: mockRunner for class: Script3
What I Think I Need
The posts I've found related to this issue all focus on soapUI TestSuites. I really need a solution that is MockService centric or at least sheds some light on how it can be handled differently for MockServices as opposed to TestSuites.
Any help is greatly appreciated. Thanks. Mark.
The Solution - Provided by GargantuChet
The following includes the changes suggested by GargantuChet to solve the problem of trying to access the ${projectDir} property and enable the use of relative paths by defining a new projectDir object within the scope of the groovy script:
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def projectDir = groovyUtils.projectPath
def req = new XmlSlurper().parseText(mockRequest.requestContent)
if (req =~ "CategoryA")
{
context.responsefile = new File(projectDir, "Test_Files/ID_List_CategoryA.xml").text
}
else
{
context.responsefile = new File(projectDir, "Test_Files/ID_List_CategoryB.xml").text
}
I'm not familiar with Groovy, but I assume the File is a normal java.io.File instance.
Relative paths are interpreted as being relative to the application's current directory. Try something like the following to verify:
def defaultPathBase = new File( "." ).getCanonicalPath()
println "Current dir:" + defaultPathBase
If this is the case here, then you may want to use the new File(String parent, String child) constructor, passing your resource directory as the first argument and the relative path as the second.
For example:
// hardcoded for demonstration purposes
def pathbase = "/Users/chet"
def content = new File(pathbase, "Desktop/sample.txt").text
println content
Here's the result of executing the script:
Chets-MacBook-Pro:Desktop chet$ groovy sample.groovy
This is a sample text file.
It will be displayed by a Groovy script.
Chets-MacBook-Pro:Desktop chet$ groovy sample.groovy
This is a sample text file.
It will be displayed by a Groovy script.
Chets-MacBook-Pro:Desktop chet$
You could have also done the following to get the value of projectDir:
def projectDir = context.expand('${projectDir}');
hoping this is an easy enough question :)
Some details:
I am using Flash CS5, never touched Flex. Also the SWF that is doing the loading will be a client SWF, so hoping for a solution that could work with a simple couple of lines.
Basically inside the SWF I am working on contains just a simple string:
var theString = "theString";
trace("theString = "+theString);
Now I've been working on a test loader SWF that will load my String SWF and get the variable in the simplest way. Any thoughts? Below is my current broken code:
function loaderComplete(event:Event)
{
trace("... in loaderComplete");
getString = loader.content.toString();
trace("loader.content = "+loader.content);
trace("... getString = "+getString);
}
This is my output window:
theString = theString
... in loaderComplete
loader.content = [object MainTimeline]
... getString = [object MainTimeline]
I've searched on Stack and found similar questions, but none are exactly what I need:
tracking video files - embedding flv to swf
^ Basically what I'm trying to do as well, no answers yet
to pass variable from one swf to another swf in as3
^ sounded just like my problem, but answer was a Flex application example
pass var values from one swf to another swf who is loaded inside the firts one in AS3
^ This was close, but am not sure how to implement the chosen answer, also seems a bit more intricate then I need
Please help!
Let's clarify a bit:
1. The loader swf, we will call the parent.
2. The swf loaded by the parent we will call the child.
The Child contains a string, and you want the parent to be able to read that string>
So...
The Child must define a public variable for the string. (This means you have to use a Class file for it, since you cannot declare a property public on the timeline.)
Finally, the parent will try and get that property. You may want to wrap that in a try/catch to handle cases where the string will not be present.
Here is an example Child Class.
package
{
import flash.display.Sprite;
/**
* ...
* #author Zach Foley
*/
public class Child extends Sprite
{
public var value:String = "This is the child Value";
public function Child()
{
trace("Child Loaded");
}
}
}
And here is the parent loader class:
package
{
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLRequest;
/**
* ...
* #author Zach Foley
*/
public class Parent extends Sprite
{
private var loader:Loader;
public function Parent()
{
trace("PArent Init");
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded);
loader.load(new URLRequest("child.swf"));
}
private function onLoaded(e:Event):void
{
trace("Child Loaded");
trace(loader.content['value']);
}
}
}
The Output will be:
PArent Init
Child Loaded
Child Loaded
This is the child Value
you can access variables and code from the loaded swf. First, make sure that both the loader and the loaded content use the same AVM, this means that both project use the same version of language (both as3 or both as2)
Thank in the loader complete handler:
loaderComplete(evt:Event):void{
var mc:MovieClip = loader.content as MovieClip;
if(!mc){
trace("Error loading");
return;
}
trace("Your string: " + mc.theString);
}
I haven't tested this code but it should works
I have made an editor extending XMLMultiPageEditorPart
now im opening a xml file in this editor
i want to make this editor read only ,
IFile file1=file...
i want the xml file which is opened in the editor to be read only.
I just resolved it.
First: you should define Instance Class of IStorage and IStorageEditorInput,You can refer to How do I open an editor on something that is not a file?
Second: Define your own XMLEditor, like this:
public class XMLEditor extends XMLMultiPageEditorPart implements IStorage{}
Last: Call editor like this:
File file= new File( path );
IWorkbenchPage page = window.getActivePage();
IStorage storage = new FileStorage(file);
IStorageEditorInput input = new XMLInput( storage );
try {
page.openEditor(input, "Your ID");
} catch (PartInitException e) {
MessageDialog.openError(window.getShell(), "", path);
}
Note: in the class FileStorage, the function getName() should return the file full path, or you will get errors.
I Hope this can help you, if you have any problem, we can discuss it, use gtalk:vvvv.spring#gmail.com
Is there a way to parse all all the classes in a groovy script?
To Parse ONE class right now:
java.lang.Class clazz = groovyClassLoader.parseClass(new File("MainApp.groovy"))
MainApp.groovy:
class MainApp {
def doIt() {}
}
class OtherMainApp {
def doTheRest() {}
}
This will return only MainApp.
I would like something like this:
java.lang.Class[] clazz = groovyClassLoader.parseClass(new File("MainApp.groovy"))
where clazz contains will contain both MainApp class and OtherMainApp class
Basically I want to be able to extract all the declared classes in a script.
Because of the nature of the app that I'm building groovyc command won't help
Thanks,
Federico
No can do:
https://issues.apache.org/jira/browse/GROOVY-3793
You could do it yourself though: you could parse the class yourself (just count the {} pairs), dump it out to a new file, and away you go. Ugly? yes. Painful? Very. Possible? Maybe. Better solution? Not until Groovy fixes the bug.
It's been 12 years since this question was asked and answered, but it arrived at the top of my Google results when I was trying to figure out how to do the same thing.
This ended up working for me:
def loader = new GroovyClassLoader()
loader.parseClass(new File("Company.groovy"))
Class Location = loader.loadClass("tk.vallerance.spacecompanies.models.Location")
Class Event = loader.loadClass("tk.vallerance.spacecompanies.models.Event")
Class Company = loader.loadClass("tk.vallerance.spacecompanies.models.Company")
println Location
println Event
println Company