Chameleon

Chameleon Svn Source Tree

Root/tags/2.0/i386/util/openUp.c

Source at commit 1672 created 12 years 7 months ago.
By blackosx, Reset language translations for the Welcome/Description and Conclusion files to english to match latest style I have for English (Sorry everyone who had previously translated). Localizable strings remain as they were as ErmaC had previously amended those to include my recent additions. French translation up to date - thanks Tenval. This will ease merging to the Trunk.
1/*
2 * Copyright (c) 2001 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22/*
23 * Shantonu Sen <<EMAIL REMOVED>>
24 * openUp.c - program to set the "first-open-window" field of a volume
25 *
26 * Get the directory ID for the first argument, and set it as word 2
27 * of the Finder Info fields for the volume it lives on
28 *
29 * cc -o openUp openUp.c
30 * Usage: openUp /Volumes/Foo/OpenMe/
31 *
32 */
33
34#include <stdio.h>
35#include <unistd.h>
36#include <stdlib.h>
37#include <sys/attr.h>
38#include <sys/stat.h>
39#include <sys/mount.h>
40#include <memory.h>
41
42struct directoryinfo {
43long unsigned length;
44uintptr_t dirid; // changed from: u_int32_t dirid;
45};
46
47struct volumeinfo {
48long unsigned length;
49uintptr_t finderinfo[8]; // changed from: u_int32_t finderinfo[8];
50};
51
52
53int main(int argc, char *argv[]) {
54char *path = NULL;
55struct attrlist alist;
56struct directoryinfo dirinfo;
57struct volumeinfo volinfo;
58struct statfs sfs;
59
60path = argv[1];
61
62bzero(&alist, sizeof(alist));
63alist.bitmapcount = 5;
64alist.commonattr = ATTR_CMN_OBJID;
65
66getattrlist(path, &alist, &dirinfo, sizeof(dirinfo), 0);
67
68printf("directory id: %lu\n", dirinfo.dirid);
69
70statfs(path, &sfs);
71
72printf("mountpoint: %s\n", sfs.f_mntonname);
73
74alist.commonattr = ATTR_CMN_FNDRINFO;
75alist.volattr = ATTR_VOL_INFO;
76
77getattrlist(sfs.f_mntonname, &alist, &volinfo, sizeof(volinfo), 0);
78volinfo.finderinfo[2] = dirinfo.dirid;
79setattrlist(sfs.f_mntonname, &alist, volinfo.finderinfo, sizeof(volinfo.finderinfo), 0);
80
81return EXIT_SUCCESS;
82}
83

Archive Download this file

Revision: 1672